简体   繁体   English

TextWriter是否有最小字符数限制

[英]Is there a minimum character limit for TextWriter

Is there a minimum content limit to use TextWriter for writing to stream 使用TextWriter写入流是否有最低内容限制

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. 我已经搜索了msdn,没有找到任何东西。

You have to flush the stream before the writes take effect. 您必须先刷新流,然后写入才能生效。 This can be accomplished by calling Flush() directly, or by closing the stream. 这可以通过直接调用Flush()或关闭流来完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM