how to write argotic.feed.save result into memory stream?

149 Views Asked by At

I want to write Argotic to memorystream and then return it as a string to another function. and this is what I've written :

            Stream st = new MemoryStream();
            Feed.Save(st); //argotic Save method has the ability to write into Stream
            StreamReader sr = new StreamReader(st);
            return sr.ReadToEnd();

but I only got an empty string although the st.length shows me the correct length but there no character in it :-?

how Can I solve this problem?

regards.

1

There are 1 best solutions below

1
On BEST ANSWER

Reset the position of the stream to 0 to read from the beginning, after the save. Otherwise you'll read from the current position, which is the end of the stream since it has just been written to:

st.Position = 0;