如果我給Process.Start();
提供參數"Firefox"
,Notepad
或"cmd"
,它會運行那些程序,就像它們的位置是內置的一樣,但是對於其他程序,我必須指定程序的目錄才能工作。c#Process.Start()方法如何自動知道文件的位置?
它如何自動知道某些程序的位置,以及爲什麼只有這些程序而不是其他程序?
我的代碼:
using System;
using System.Diagnostics;
namespace Testing
{
public class MainClass
{
static void Main()
{
Process.Start("Firefox"); // Works
Process.Start("Notepad"); // Works
Process.Start(@"C:\Users\user\Desktop\Steam"); // Works too
Process.Start("Steam"); // This line gives me "The System cannot find the file specified"(run-time error)
}
}
}
與'Run'thingy(Windows + R)相同,可能是PATH變量。 – 2015-01-31 18:45:58