对比新文件 |
| | |
| | | 锘縰sing System; |
| | | using System.IO; |
| | | using System.Threading; |
| | | |
| | | namespace LogLibrary.Log |
| | | { |
| | | public static class FileUtil |
| | | { |
| | | |
| | | /// <summary> |
| | | /// 杩藉姞鍐呭鍒版寚瀹氭枃浠朵腑 |
| | | /// </summary> |
| | | /// <param name="filePath"></param> |
| | | /// <param name="content"></param> |
| | | public static void WriteAppend(string filePath, string content) |
| | | { |
| | | WriteAppend(filePath, new string[] { content }); |
| | | } |
| | | |
| | | public static void WriteAppend(string filePath, string[] contents) |
| | | { |
| | | using (FileStream fs = new(filePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite)) |
| | | { |
| | | fs.Seek(fs.Length, SeekOrigin.Current); |
| | | |
| | | string content = string.Join(Environment.NewLine, contents) + Environment.NewLine; |
| | | |
| | | //byte[] data = System.Text.Encoding.GetEncoding("GB2312").GetBytes(content); |
| | | byte[] data = System.Text.Encoding.Default.GetBytes(content); |
| | | |
| | | |
| | | fs.Write(data, 0, data.Length); |
| | | |
| | | fs.Close(); |
| | | fs.Dispose(); |
| | | } |
| | | } |
| | | } |
| | | } |