txt文件操作

asp.net 读取txt文件

StreamReader sr = new StreamReader(MapPath("weather.txt"), System.Text.Encoding.Default);
String input = sr.ReadToEnd();
sr.Close();

asp.net修改txt文件2008-01-25 18:34

string path = "D:\\56huiWord\\test.txt";
StreamWriter sw = File.CreateText("D:\\56huiWord\\temp.txt");
sw.WriteLine("aaaaaaaaaa");
sw.WriteLine("bbb");
sw.Flush();
sw.Close();

File.Delete(fileName);
File.Copy("D:\\56huiWord\\temp.txt", fileName);
File.Delete("D:\\56huiWord\\temp.txt");

原文地址:https://www.cnblogs.com/lfzm/p/2073937.html