kishore
kishore

Reputation: 727

Is there a minimum character limit for TextWriter

Is there a minimum content limit to use TextWriter for writing to stream

MemoryStream ms = new MemoryStream();    
TextWriter textWriter = new StreamWriter(ms);

Below code does not write data to stream. And stream is empty

for (int ix = 0; ix < 10; ix++)
{
textWriter.WriteLine(ix.ToString());
}

Below code writes the data to stream

for (int ix = 0; ix < 1000; ix++)
{
textWriter.WriteLine(ix.ToString());
}

I have searched msdn and did not find any thing.

Upvotes: 0

Views: 85

Answers (1)

Erik Funkenbusch
Erik Funkenbusch

Reputation: 93444

You have to flush the stream before the writes take effect. This can be accomplished by calling Flush() directly, or by closing the stream.

Upvotes: 3

Related Questions