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("转换完成");