Streamwriter C#

Asked

Viewed 33 times

1

I have the following code:

using (var stream = new System.IO.StreamWriter(System.IO.File.Open("c:\\file.xml", 
FileMode.OpenOrCreate, FileAccess.ReadWrite)))
{
    infoSerializer.Serialize(stream,
                Functions.ConvertLayoutConsultarSituacaoLoteRpsEnvio(objeto,
                                     Functions.PadraoNFSe(codigoMunicipio)));
    stream.Close();
}

In case the Streamwriter creates a file in the C directory: but instead of creating a file I wanted to save the information in memory, whether in a Stream or even in a string, how should I change this code snippet so I can make this change?

  • What "information" you want?

  • It creates an Xml file from an Nfse batch query.

  • And what you want to do?

  • Instead of saving this xml to a physical file, I would like to save the content to a string or stream, without creating the . xml file

  • This was answered in the linked question.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.