如何打开一个exe。使用 C# 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17207173/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to open a exe. file using c#
提问by Yukimoto Otomikuy
hello guys can anyone tell me how to open a executable file in Visual-studio using Buttonlike when i click the button it will open the calculator or notepad :)
大家好,谁能告诉我如何在 Visual-studio 中打开一个可执行文件,Button就像当我单击按钮时它会打开计算器或记事本 :)
回答by Jonathon Reinhart
Use Process.Start.
Process.Start("notepad.exe");
From MSDN:
来自 MSDN:
Starting a process by specifying its file name is similar to typing the information in the Run dialog box of the Windows Start menu. Therefore, the file name does not need to represent an executable file. It can be of any file type for which the extension has been associated with an application installed on the system.
通过指定文件名启动进程类似于在 Windows 开始菜单的运行对话框中键入信息。因此,文件名不需要代表可执行文件。它可以是扩展名与系统上安装的应用程序相关联的任何文件类型。
回答by Soner G?nül
You can use Process.Startmethod like;
您可以使用Process.Start类似的方法;
Starts a process resource and associates it with a Process component.
启动流程资源并将其与流程组件相关联。
Process.Start("calc.exe");
Process.Start("notepad.exe");
Starting a process by specifying its file name is similar to typing the information in the Rundialog box of the Windows Startmenu. Therefore, the file name does not need to represent an executable file. It can be of any file type for which the extension has been associated with an application installed on the system. For example the file name can have a .txt extension if you have associated text files with an editor, such as Notepad, or it can have a .doc if you have associated.doc files with a word processing tool, such as Microsoft Word. Similarly, in the same way that the Run dialog box can accept an executable file name with or without the .exe extension, the .exe extension is optional in the fileName parameter. For example, you can set the fileName parameter to either "Notepad.exe" or "Notepad".
通过指定文件名启动进程类似于在 Windows开始的运行对话框中键入信息菜单。因此,文件名不需要代表可执行文件。它可以是扩展名与系统上安装的应用程序相关联的任何文件类型。例如,如果您将文本文件与记事本等编辑器相关联,则文件名可以具有 .txt 扩展名;如果您将 .doc 文件与字处理工具(如 Microsoft Word)相关联,则文件名可以具有 .doc。同样,与“运行”对话框可以接受带有或不带有 .exe 扩展名的可执行文件名一样,.exe 扩展名在 fileName 参数中是可选的。例如,您可以将 fileName 参数设置为“Notepad.exe”或“Notepad”。
回答by Soner G?nül
Use the System.Diagnostics.Process.Start()method.
使用System.Diagnostics.Process.Start()方法。
Check out this articleon how to use it.
查看这篇文章,了解如何使用它。
回答by kostas ch.
Use the above
使用以上
// run notepad
System.Diagnostics.Process.Start("notepad.exe");
//run calculator
System.Diagnostics.Process.Start("calc.exe");

