運行控制檯應用程序。如果bool User
是true
,我想輸出文本到控制檯應用程序。 if bool User
is false
我想創建一個文件並將文本輸出到那裏。創建一個文本文件並在bool爲false時寫入它
適用於true
,並創建文本文件if false
,但不保存文本。
任何想法?
if (!user)
{
Console.SetOut(File.CreateText(@".\log" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".log"));
OutputHeader();
}
Console.WriteLine("Arg count is " + args.Length.ToString());
Console.WriteLine("Show verbose output is = " + verbose.ToString());