标签:blog ar os 文件 on div log as line
Console.WriteLine("Hello World"); FileStream fs1 = new FileStream("Test.txt", FileMode.Create); // First, save the standard output. TextWriter tmp = Console.Out; StreamWriter sw1 = new StreamWriter(fs1); Console.SetOut(sw1); Console.WriteLine("Hello file"); Console.SetOut(tmp); Console.WriteLine("Hello World"); sw1.Close();
设置到FileStream就是输出到文本文件,设置为Console.Out就是输出到命令行窗口
标签:blog ar os 文件 on div log as line
原文地址:http://www.cnblogs.com/techfans/p/4108956.html