可能重複:
How can I determine whether Console.Out has been redirected to a file?
How to detect if Console.In (stdin) has been redirected?控制檯重定向與Console.CursorLeft
我們的系統目前使用CursorLeft
函數寫在那個被印刷到控制檯的最後一件事窗口:
Console.CursorLeft = 0;
這是必需的功能,所以我無法將其更改爲每次只打印一個新行。
將控制檯重定向到文本文件時,發生IOException
。我怎樣才能讓日誌文件跳過顯示這些輸出或強制它寫出每個人?