让我们说我正在尝试使用以下代码创建一个新进程:
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
p.StartInfo.FileName = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\AwesomeFile.exe";
p.StartInfo.Arguments = "parameter1 parameter2";
p.StartInfo.CreateNoWindow = true;
p.Start();
Run Code Online (Sandbox Code Playgroud)
在下一行中,我将尝试使用以下行获取该进程的pid:
MessageBox.Show(p.Id);
Run Code Online (Sandbox Code Playgroud)
这一行给了我"没有进程与此对象相关联".错误.知道为什么会出现这个错误吗?
| 归档时间: |
|
| 查看次数: |
9977 次 |
| 最近记录: |