当前位置: 动力学知识库 > 问答 > 编程问答 >

wpf - When adding command line arguments from the project's Start Options, the vshost.exe is added as an argument

问题描述:

If I put two arguments in that field, it shows three because it gives me the vshost.exe process as well.

It's throwing off my debugging. Anyone know either a way to fix this or an alternate method of getting the command line arguments in WPF?

I'm currently getting them via:

string[] args = Environment.GetCommandLineArgs();

网友答案:

The first argument is always the process name.

When you run the exe outside the debugger the first argument will be "MyApplication.exe".

You should start your processing of the command line arguments from index 1.

The first element in the array contains the file name of the executing program. If the file name is not available, the first element is equal to String.Empty. The remaining elements contain any additional tokens entered on the command line.

Source

分享给朋友:
您可能感兴趣的文章:
随机阅读: