我有一个文件,我打开流并传递给另一个方法.但是,我想在将流传递给另一个方法之前替换文件中的字符串.所以:
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);
Run Code Online (Sandbox Code Playgroud)
不应修改原始文件,仅修改流.最简单的方法是什么?
谢谢...