using System.IO;
namespace streamWrite方法
{
    class Program
    {
        static void Main(string[] args)
        {
            string path = "D:\\123\\123.txt";
            string conTent = "中华人民共和国万岁,世界人民大团结万岁!";
            FileStream fs = new FileStream(path,FileMode.OpenOrCreate);
            StreamWriter sw = new StreamWriter(fs);
            sw.WriteLine(conTent);  //写入一行内容
            sw.Close();
            Console.Write("写入成功~!");
            Console.ReadKey();
        }
    }
}

 

posted on 2022-06-02 19:20  sbwynnss  阅读(592)  评论(0)    收藏  举报