我正在尝试将命令行参数传递给一个C#应用程序,但是我无法正确地传递类似于这样的参数
"C:\Documents and Settings\All Users\Start Menu\Programs\App name"
即使我在参数中添加了" "
,结果也是一样的。
这里是我的代码:
public ObjectModel(String[] args)
{
if (args.Length == 0) return; //no command line arg.
//System.Windows.Forms.MessageBox.Show(args.Length.ToString());
//System.Windows.Forms.MessageBox.Show(args[0]);
//System.Windows.Forms.MessageBox.Show(args[1]);
//System.Windows.Forms.MessageBox.Show(args[2]);
//System.Windows.Forms.MessageBox.Show(args[3]);
if (args.Length == 3)
{
try
{
RemoveInstalledFolder(args[0]);
RemoveUserAccount(args[1]);
RemoveShortCutFolder(args[2]);
RemoveRegistryEntry();
}
catch (Exception e)
{
}
}
}
这里是我正在传递的内容:
C:\WINDOWS\Uninstaller.exe "C:\Program Files\Application name\" "username" "C:\Documents and Settings\All Users\Start Menu\Programs\application name"
问题是我可以正确获取前两个参数,但最后一个参数获取为C:\Documents
。有帮助吗?