c# 写文件操作
写文本到指定文件:
var fs = new FileStream(filePath, FileMode.Create); StreamWriter sw = new StreamWriter(fs); sw.WriteLine("hello text"); sw.Flush(); sw.Close(); fs.Close();
读取文件
StreamReader sr = new StreamReader(file, Encoding.Default); string urlText = sr.ReadLine(); sr.Close();