asp.net 追加文本(追加写入记事本)

代码:

 1 string path = Server.MapPath("/Log/Log.txt");
 2 if (File.Exists(path))
 3 {
 4      using (StreamWriter sw = File.AppendText(path))
 5      {
 6          sw.WriteLine("文本内容");
 7          sw.Flush();
 8          sw.Close();
 9       }
10 }
11 else
12 {
13       using (StreamWriter sw = File.CreateText(path))
14       {
15           sw.WriteLine("文本内容");
16           sw.Flush();
17           sw.Close();
18       }
19 }

 

posted @ 2014-04-23 20:32  追逐者——Eagle  阅读(1101)  评论(0编辑  收藏  举报