C#文件写入操作

using System;
using System.IO;

namespace IO操作
{
    class Program
    {
        static void Main(string[] args)
        {
            using(StreamWriter w=File.AppendText("IO.txt"))
            {
                TextIn("Hello GeoStorm", w);
                TextIn("Hello World",w);
                w.Close();
            }
        }
        public static void TextIn(string content, TextWriter w)
        {
            w.Write("\r\n message:");
            w.WriteLine("{0}",content);
            w.Flush();
        }
    }
}

你可能感兴趣的:(C#文件写入操作)