相关疑难解决方法(0)

用C#替换流中的字符串(不覆盖原始文件)

我有一个文件,我打开流并传递给另一个方法.但是,我想在将流传递给另一个方法之前替换文件中的字符串.所以:

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)

不应修改原始文件,仅修改流.最简单的方法是什么?

谢谢...

.net c# string filestream

10
推荐指数
1
解决办法
1万
查看次数

标签 统计

.net ×1

c# ×1

filestream ×1

string ×1