在服务器上创建 .txt 文件

 1         context = HttpContext.Current;
 2         string ServerPath = HttpContext.Current.Server.MapPath("~");
 3         string FilePath = ServerPath + "\\wx\\weixin.txt";
 4         if (File.Exists(FilePath))
 5         {
 6             File.Delete(FilePath);
 7         }
 8         string strCon = Request.Url.ToString();
 9         StreamWriter _StreamWriter = new StreamWriter(FilePath, false, System.Text.Encoding.GetEncoding("GB2312"));
10         _StreamWriter.WriteLine(strCon);
11         _StreamWriter.Flush();
12         _StreamWriter.Close();

 

posted @ 2013-11-26 15:21  duanyong  阅读(699)  评论(0编辑  收藏  举报