[DllImport("kernel32.dll")] static extern uint GetTempPath(uint nBufferLength, [Out] StringBuilder lpBuffer);[ DllImport("shell32.dll", EntryPoint="FindExecutable")] static extern long FindExecutableA(string lpFile, string lpDirectory, [Out] StringBuilder lpResult); public static string GetExePathFileFromExtention(string extension) { string tempFileName = Path.ChangeExtension(Path.GetTempFileName(), extension); string tempPathFile = Path.Combine("temp", tempFileName); StringBuilder sb = new StringBuilder(1024); File.Create(tempFileName); long ret = FindExecutableA(tempFileName, string.Empty, sb); if (ret >= 32) return sb.ToString(); else return string.Empty; }