码迷,mamicode.com
首页 > 其他好文 > 详细

记录日志到txt文件

时间:2015-08-25 15:54:49      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

 

        public void writetxt(string content)
        {
            string filePath = Server.MapPath("data.txt");
            int len = content.Length;
            byte[] inputByts = new byte[len];
            inputByts = Encoding.GetEncoding("utf-8").GetBytes(content);
            System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.OpenOrCreate);
            fs.Seek(0, System.IO.SeekOrigin.End);
            fs.Write(inputByts, 0, inputByts.Length);
            fs.Close();//关闭流

        }

 

记录日志到txt文件

标签:

原文地址:http://www.cnblogs.com/bweb/p/4757321.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!