首页 > 其他 > 详细

记录日志到txt文件

时间:2015-08-25 15:51:38      阅读:156      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!