如果我运行一个带ShellExecute
的进程(或在带System.Diagnostics.Process.Start()
的.Net中),启动的文件名进程不需要是完整路径.
如果我想启动记事本,我可以使用
Process.Start("notepad.exe");
而不是
Process.Start(@"c:\windows\system32\notepad.exe");
因为direcotry c:\windows\system32
是PATH环境变量的一部分.
如何在不执行流程和不解析PATH变量的情况下判断路径上是否存在文件?
System.IO.File.Exists("notepad.exe"); // returns false
(new System.IO.FileInfo("notepad.exe")).Exists; // returns false
但我需要这样的东西:
System.IO.File.ExistsOnPath("notepad.exe"); // should return true
和
System.IO.File.GetFullPath("notepad.exe"); // (like unix which cmd) should return
// c:\windows\system32\notepad.exe
BCL中是否有用于执行此任务的预定义类?