关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

C#修改记事本中指定的值

发布时间:2019-12-27 18:07:37

string path = @"D:\Users\Desktop\123";
string[] pathFile = Directory.GetFiles(path);
string con = "";
foreach (string str in pathFile)
{
    FileStream fs = new FileStream(str, FileMode.Open, FileAccess.Read);
    StreamReader sr = new StreamReader(fs);
    con = sr.ReadToEnd();
    con = con.Replace("内容", "替换内容");
    sr.Close();
    fs.Close();
    FileStream fs2 = new FileStream(str, FileMode.Open, FileAccess.Write);
    StreamWriter sw = new StreamWriter(fs2);
    sw.WriteLine(con);
    sw.Close();
    fs2.Close();
}
MessageBox.Show("转换完成");


/template/Home/Zkeys/PC/Static