C#-创建并添加TXT文件

public static void WriteToText(string txtContent, string txtPath)
{
    using (FileStream fs = new FileStream(txtPath, FileMode.OpenOrCreate,FileAccess.Write))
    {
        using (StreamWriter sw=new StreamWriter(fs))
        {
            sw.BaseStream.Seek(0, SeekOrigin.End);
            sw.WriteLine("{0}
", txtContent);
            sw.Flush();
        }
    }
}
原文地址:https://www.cnblogs.com/zhyue93/p/CSharp_Text.html