【发布时间】:2013-09-16 19:33:21
【问题描述】:
我有一个文件要打开到流中并传递给另一个方法。但是,我想在将流传递给其他方法之前替换文件中的字符串。所以:
string path = "C:/...";
Stream s = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
//need to replace all occurrences of "John" in the file to "Jack" here.
CallMethod(s);
不应修改原始文件,只能修改流。最简单的方法是什么?
谢谢...
【问题讨论】:
-
你可以在这里用 StreamReader 阅读它:msdn.microsoft.com/en-us/library/system.io.streamreader.aspx
标签: c# .net string filestream