StreamWriter(流形式写入文本文件)

来源:互联网 发布:软件下载大全360 编辑:程序博客网 时间:2024/06/07 09:07
static void Main(string[] args)
        {
            //StreamReader sr = new StreamReader("x.txt", Encoding.Default);
            //{
            //    sr.Read();
            //}
            using(StreamWriter sw = new StreamWriter("k.txt", true, Encoding.Default))
            {
                //sw.WriteLine("{0}+{1}={2}", 3, 4, 3 + 4);
                while (true)
                {
                    string input = Console.ReadLine();
                    if (input == "q")
                    {
                        break;
                    }
                    sw.WriteLine(input);
                }
            }
        }
0 0
原创粉丝点击