Stream without content C #

0

Good afternoon guys I have the following code:

 Stream retorno = new MemoryStream();

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

            StreamReader reader = new StreamReader(retorno);

            Repositorio.XmlConsultarLote = reader.ReadToEnd();

        }

        using (var stream = new System.IO.StreamWriter(retorno))
        {
            infoSerializer.Serialize(stream, Functions.ConvertLayoutConsultarSituacaoLoteRpsEnvio(objeto, Functions.PadraoNFSe(codigoMunicipio)));

            StreamReader reader = new StreamReader(retorno);

            Repositorio.XmlConsultarLote = reader.ReadToEnd();

        }

The first using is how the function was originally, and the second using is what I am trying to change, well ... the purpose and not need to create a physical file on the machine, for this I am trying instead of creating the file I am trying to pass the content to a stream, however when I get to the Repositorio.XmlConsultarLote = reader.ReadToEnd(); Repository.XmlConsultLote does not receive anything, does it know where the error is?

    
asked by anonymous 08.06.2017 / 19:52

0 answers