Compruebe si existe un ejecutable en la ruta de Windows
Si ejecuto un proceso conShellExecute
(o en .net conSystem.Diagnostics.Process.Start()
) el proceso de nombre de archivo para comenzar no necesita ser una ruta completa.
Si quiero iniciar el bloc de notas, puedo usar
Process.Start("notepad.exe");
en lugar de
Process.Start(@"c:\windows\system32\notepad.exe");
porque el direcotryc:\windows\system32
es parte de la variable de entorno PATH.
¿Cómo puedo verificar si existe un archivo en la RUTA sin ejecutar el proceso y sin analizar la variable RUTA?
System.IO.File.Exists("notepad.exe"); // returns false
(new System.IO.FileInfo("notepad.exe")).Exists; // returns false
pero necesito algo como esto:
System.IO.File.ExistsOnPath("notepad.exe"); // should return true
y
System.IO.File.GetFullPath("notepad.exe"); // (like unix which cmd) should return
// c:\windows\system32\notepad.exe
¿Hay una clase predefinida para hacer esta tarea disponible en el BCL?