手写日志

手写日志

 private static void Writelog(string log)
        {
            string path = AppDomain.CurrentDomain.BaseDirectory;
            string fileName = DateTime.Now.ToString("yyyyMMdd") + ".log";
            var filePath = Path.Combine(path, fileName);
            using (FileStream fs=new FileStream (filePath,FileMode.OpenOrCreate))
            {
                fs.Position = fs.Length;
                var bytes = System.Text.Encoding.UTF8.GetBytes(log);
                fs.Write(bytes, 0, bytes.Length);
                fs.Flush();
            }
        }

你可能感兴趣的:(c#)