为什么是这样
ProcessStartInfo myProcess = new ProcessStartInfo(path);
myProcess.UserName = username;
myProcess.Password = MakeSecureString(password);
myProcess.UseShellExecute = false;
Process.Start(myProcess);
工作,但是
ProcessStartInfo myProcess = new ProcessStartInfo();
myProcess.FileName = Path.GetFileName(path);
myProcess.WorkingDirectory = Path.GetDirectoryName(path);
myProcess.UserName = username;
myProcess.Password = MakeSecureString(password);
myProcess.UseShellExecute = false;
Process.Start(myProcess);
不是。
由于这个问题,我想使用第二个:https ://stackoverflow.com/a/2621943/1306186
我不断收到文件未找到异常...有什么想法吗?
编辑:
路径例如@"C:\Users\User\Desktop\ConsoleApplication2.exe"