using 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(); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
} 
 |