简体   繁体   English

读取很长的一行文字 C#

[英]Read a very long line of text C#

I want to read a very long line of text using C#.我想使用 C# 阅读很长的一行文本。 The length of the line is about 100000 chars.该行的长度约为 100000 个字符。 I am using StreamReader.ReadLine() method.我正在使用 StreamReader.ReadLine() 方法。 I also want to write this long string to a file.我也想把这个长字符串写到一个文件中。 One of them or both are not working properly.其中之一或两者都无法正常工作。 I could only write 99328 characters to a file.我只能将 99328 个字符写入文件。 How can I read and write a very long line of text using C#?如何使用 C# 读写很长的文本行?

I suspect that you did not close your output buffer and it's not completing the file write.我怀疑您没有关闭 output 缓冲区并且它没有完成文件写入。

Consider using File.ReadAllText考虑使用 File.ReadAllText

http://msdn.microsoft.com/en-us/library/ms143368.aspx http://msdn.microsoft.com/en-us/library/ms143368.aspx

and File.WriteAllText和 File.WriteAllText

http://msdn.microsoft.com/en-us/library/ms143375.aspx http://msdn.microsoft.com/en-us/library/ms143375.aspx

You are probably failing to call.Flush() on your output stream.您可能无法在 output stream 上调用.Flush()。

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

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