![](/img/trans.png)
[英]C# Console Application: Is there a way to detect whether the exe was run from a command line or not?
[英]How to detect internally whether the application is in console or windows mode in C#
有沒有辦法從應用程序本身檢查程序是處於控制台還是Windows模式? 我知道Read和ReadLine可以以某種方式檢測到這一點,但是如何?
您應該能夠檢查Console.In == StreamReader.Null;
如果是這樣,則沒有連接控制台。 例如,以下適用於此:
public static bool IsConsoleApplication
{
get { return Console.In != StreamReader.Null; }
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.