记录日志到txt文件

 

        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();//关闭流

        }

 

posted @ 2015-08-25 14:22  石中隐鱼  阅读(296)  评论(0编辑  收藏  举报