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("转换完成");
Copyright © 2004-2024 Ynicp.com 版权所有 法律顾问:建纬(昆明)律师事务所 昆明市网翼通科技有限公司 滇ICP备08002592号-4