我已经创建了.exe文件的快捷方式.
我想添加'.exe'额外参数.(在快捷方式:目标属性)
示例
目标:
"C:\ Documents and Settings\dezigo\My Documents\c#programm\DirectoryScanner\DirectoryScanner\DirectoryScanner\bin\Debug\DirectoryScanner.exe "+额外的parrams(如方法= 1)
如何在我的软件中读取这些参数?(c#)
然后,当启动.exe
检查
if(method == 1)
{
//do something
}
else
{
//do something
}
Run Code Online (Sandbox Code Playgroud)
您可以使用Environment.CommandLine属性来获取运行可执行文件时传递的命令行,并解析它以获取参数.参数也将在Main方法中传递:
class Program
{
static void Main(string[] args)
{
// The args array will contain the arguments passed at the command line
// For example if the executable has been launched like:
// "DirectoryScanner.exe method=1"
// args[0] will contain "method=1"
}
}
Run Code Online (Sandbox Code Playgroud)