From 202cdf4c400f7b8507f129fab5766baac6bc7e45 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期二, 11 三月 2025 17:40:20 +0800 Subject: [PATCH] 1 --- 项目代码/WMS/WIDESEA_WMSServer/LogLibrary/Log/FileUtil.cs | 39 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/LogLibrary/Log/FileUtil.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/LogLibrary/Log/FileUtil.cs" new file mode 100644 index 0000000..2aaeea4 --- /dev/null +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/LogLibrary/Log/FileUtil.cs" @@ -0,0 +1,39 @@ +锘縰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(); + } + } + } +} -- Gitblit v1.9.3