我知道如何运行在C# System.Diagnostics.Process.Start(executableName)外部应用;
但如果我要运行的应用程序扩展名是不能被Windows识别为扩展名的可执行文件。在我的情况下,它是 application.bin
。
I know how to run an external application in C# System.Diagnostics.Process.Start(executableName);
but what if the application I want to run has extension that is not recognizable by Windows as extension of an executable. In my case it is application.bin
.
问候。
关键是设置 Process.StartInfo.UseShellExecute
属性假
之前,要启动的过程中,例如:
Key is to set the Process.StartInfo.UseShellExecute
property to false
prior to starting the process, e.g.:
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = @"c:\tmp\test.bin";
p.StartInfo.UseShellExecute = false;
p.Start();
这将直接启动程序。而不是去通过让我们尝试找出可执行文件指定的文件扩展名贝逻辑,该文件将被认为是可执行文件本身
This will start the process directly: instead of going through the "let's try to figure out the executable for the specified file extension" shell logic, the file will be considered to be executable itself.
另一个语法来实现相同的结果可能是:
Another syntax to achieve the same result might be:
var processStartInfo = new ProcessStartInfo
{
FileName = @"c:\tmp\test.bin",
UseShellExecute = false
};
Process.Start(processStartInfo);