12345678910111213141516171819202122232425262728293031323334353637383940 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace vCloud.Windows.ForceUpgrade
- {
- public static class FileHelper
- {
- /// <summary>
- /// 追加写入文件
- /// </summary>
- /// <param name="fileName">文件名</param>
- /// <param name="contexts">文件内容</param>
- /// <param name="encodingStr">文件编码</param>
- public static void AppendWriteFile(string fileName, string contexts, string encodingStr = "UTF-8")
- {
- try
- {
- if (!string.IsNullOrEmpty(fileName))
- {
- using (FileStream fs = new FileStream(fileName, FileMode.Append, FileAccess.Write, FileShare.ReadWrite))
- {
- Encoding textEncoding = Encoding.GetEncoding(encodingStr.ToUpper());
- using (StreamWriter streamWriter = new StreamWriter(fs, textEncoding))
- {
- streamWriter.Write(contexts);
- }
- }
- }
- }
- catch
- {
-
- }
- }
- }
- }
|