C#怎么实现一个目录下面所有后缀名相同的文件的关键字替换。怎么对文件先读后写。求代码
例如在目录ttt下面替换所有后缀名为txt文件的很多行 strLine = strLine.Replace(@"./xcode.configVpp.pl -frmrate 5 -height" + height1 + "-width" + width1 + " -vidformat 1 -instance" + ins[z], @"./xcode.configVpp.pl -frmrate 5 -height" + height + "-width" + width + " -vidformat 1 -instance" + ins[z]); width和height是变量 c#
例如在目录ttt下面替换所有后缀名为txt文件的很多行 strLine = strLine.Replace(@"./xcode.configVpp.pl -frmrate 5 -height" + height1 + "-width" + width1 + " -vidformat 1 -instance" + ins[z], @"./xcode.configVpp.pl -frmrate 5 -height" + height + "-width" + width + " -vidformat 1 -instance" + ins[z]); width和height是变量 c#
解决方案 »
- 关于“VS2008试用期评估已经结束。”问题
- 求U盘误删恢复软件的工作原理
- c# 预分配流水编号(未保存),如何处理多用户并发访问?
- winform 界面显示 的难题
- 用ole控件访问ACCESS数据库报错,请高人指教
- 好郁闷的问题:我添加WebBrowser控件到工具箱,为什么在工具箱中找不到?
- 求GB/T 3304-1991 中国各民族名称的罗马字母拼写法和代码
- 怎么确定函数,在内存中的地址?
- C#开发称重系统,如何通过串口读取电子磅的数据?
- 急求:treeview中显示节点问题
- C#固定宽度生成缩略图
- x86程序移植到x64后,“CPU采样”性能分析显示,clr.dll独占样本数最多,达到70%左右。但在x86下clr.dll独占样本数0.5%,这是为什么?
List<string> ls = Directory.EnumerateFiles("文件目录", "*.txt").ToList();
foreach (string s in ls)
{
string st = File.ReadAllText(s, Encoding.Default);
st = st.Replace("旧值", "新值");
File.Delete(s);
File.WriteAllText(s,st,Encoding .Default);
}