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