使用 Process.Start 运行程序时,找不到其资源文件

Din*_*tin 3 c# graphics process

我有这个代码:

private void button1_Click(object sender, EventArgs e)
{
    Process p = new Process();
    p.StartInfo.FileName = "C:/Users/Valy/Desktop/3dcwrelease/3dcw.exe";
    p.Start();
}
Run Code Online (Sandbox Code Playgroud)

3dcw.exe是一个用于 OpenGL 图形的应用程序。

问题是,当我单击按钮时,可执行文件会运行,但无法访问其纹理文件。

有没有人有办法解决吗?我想在后台加载位图文件,然后运行exe文件,但我该怎么做呢?

Dan*_*ana 6

我在互联网上搜索了您问题的解决方案,并找到了这个网站:http ://www.widecodes.com/0HzqUVPWUX/i-am-lauching-an-opengl-program-exe-file-from-visual-基本但纹理缺失什么是错误的.html

在 C# 代码中,它看起来像这样:

string exepath = @"C:\Users\Valy\Desktop\3dcwrelease\3dcw.exe";
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = exepath;
psi.WorkingDirectory = Path.GetDirectoryName(exepath);
Process.Start(psi);
Run Code Online (Sandbox Code Playgroud)