c# Process Start 启动所需的应用程序,但该应用程序运行不正常
c# Process Start launch the desired application but that application doesn't work well
我有一个可以启动多个游戏的程序。我有一款游戏会创建一个包含玩家进度的 json 文件,问题是当我手动打开此游戏(来自 windows)时,json 文件已正确创建并且游戏运行好吧,但是当我从我的应用程序打开同一个游戏时,游戏会执行,但效果不佳,因为从未创建 json 文件,当我尝试读取另一个 json 我之前创建的文件时游戏无法读取它们。
我检查了我的程序中的游戏路径是否错误,但事实并非如此。
我读了一些关于 process.start 的其他帖子,我看到的唯一有用的帖子是关于进程模拟的,但我不知道如何使用它或你用它做什么。我想我的问题是权限不足。
这是我启动游戏的代码:
string downloadPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"Outlands Adventure Client");
string gamePath = Path.Combine(downloadPath, currentGameInfo.GameName, currentGameInfo.GameName + ".exe");
MessageBox.Show(gamePath);
Process.Start(gamePath);
这是我的消息框显示的游戏路径:
提前致谢
将工作目录设置为游戏目录,如:
var process = new System.Diagnostics.Process();
process.StartInfo.WorkingDirectory = <...>;
process.StartInfo.FileName = <...>;
process.Start();
我有一个可以启动多个游戏的程序。我有一款游戏会创建一个包含玩家进度的 json 文件,问题是当我手动打开此游戏(来自 windows)时,json 文件已正确创建并且游戏运行好吧,但是当我从我的应用程序打开同一个游戏时,游戏会执行,但效果不佳,因为从未创建 json 文件,当我尝试读取另一个 json 我之前创建的文件时游戏无法读取它们。 我检查了我的程序中的游戏路径是否错误,但事实并非如此。 我读了一些关于 process.start 的其他帖子,我看到的唯一有用的帖子是关于进程模拟的,但我不知道如何使用它或你用它做什么。我想我的问题是权限不足。
这是我启动游戏的代码:
string downloadPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"Outlands Adventure Client");
string gamePath = Path.Combine(downloadPath, currentGameInfo.GameName, currentGameInfo.GameName + ".exe");
MessageBox.Show(gamePath);
Process.Start(gamePath);
这是我的消息框显示的游戏路径:
提前致谢
将工作目录设置为游戏目录,如:
var process = new System.Diagnostics.Process();
process.StartInfo.WorkingDirectory = <...>;
process.StartInfo.FileName = <...>;
process.Start();