记录日志到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();//关闭流

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