我想让Windows窗体应用程序使用带有三个选项的菜单栏来启动控制台应用程序。 控制台应用程序是Visual Studio中用C#构建的.exe文件,其中包含一些用于学校项目的基本代码。 控制台应用程序不需要返回任何值,只需运行并允许用户使用它。 这就是表单的样子: 菜单应用程序
我尝试在我的菜单项单击事件方法中使用Process.Start@("Path of file")导入System.Diagnostics.Process.Start命名空间以启动我的C#控制台应用程序,但尚未成功。 我得到一个“Win32Exception is unhandled:System.dll中发生未处理的类型'System.ComponentModel.Win32Exception'的异常。其他信息:系统找不到指定的文件”
以下是菜单项单击事件中的代码:
public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void lesson13LabCToolStripMenuItem_Click(object sender, EventArgs e) { Process.Start(@"\C:\Users\Sam\Documents\Visual Studio 2015\Projects\LabMenu\LabMenu\Lesson13LabC.exe"); } }关于我做错什么的想法?
I want to have a Windows Form Application use a menustrip with three options to launch a console application. The console application is a .exe file built in C# in Visual Studio with some basic code for as school project. The console application does not need to return any values, it only needs to run and allow the user to use it. This is what the form will look like: Menu Application
I have tried importing the System.Diagnostics.Process.Start namespace with Process.Start@("Path of file") in my menu item click event method to launch my C# console application but have not been successful. I am getting a "Win32Exception was unhandled: An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll. Additional information: The system cannot find the file specified"
Here is the code in the menu item click event:
public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void lesson13LabCToolStripMenuItem_Click(object sender, EventArgs e) { Process.Start(@"\C:\Users\Sam\Documents\Visual Studio 2015\Projects\LabMenu\LabMenu\Lesson13LabC.exe"); } }Any ideas on what I am doing wrong?
最满意答案
错误很明显The system cannot find the file specified 。 检查文件的路径。
还要删除路径中的起始\
The error is clear The system cannot find the file specified. Check the path of file.
Also remove the starting \ in the path
更多推荐
发布评论