使用 Process.Start(*vscode.exe-path*, *file path*) 打开文件时文件为空

问题描述

我想允许用户从我的应用程序中加载 VSCode 中的 python 项目。用户会得到一个项目列表,他从中选择一个,点击后应该会在 VSCode 中打开。项目文件夹和文件位于 C:\Users\Korisnik\Documents\Pygame Engine

我正在尝试使用位于 C:\Users\Korisnik\Documents\Pygame Engine\Test 的 c# 代码打开 .py 文件 Process.Start(@"C:\Users\Korisnik\AppData\Local\Programs\Microsoft VS Code\code.exe",projectPath + "\\" + projectName + ".py");

projectPath 变量是项目 (C:\Users\Korisnik\Documents\Pygame Engine\Test) 的路径,在本例中,projectName 是“Test”。 test 文件夹包含 Test.py 文件

我之前在那个 .py 文件中编写了一些代码,但是当 VSCode 打开时,文件名看起来像一个选项卡,但没有代码。当我保存它时,它会保存在 C:\Users\Korisnik\source\repos\Pygame Engine\Pygame Engine\bin\Debug\netcoreapp3.1\Engine\Test

另一方面,当我尝试用带有 Process.Start(@"C:\Windows\system32\notepad.exe",projectPath + "\\" + projectName + ".py"); 的记事本打开它时,代码被加载并保存在 C:\Users\Korisnik\Documents\Pygame Engine\Test 中,它应该在那里。

我只需要在 VSCode 中打开该文件并且用户能够修改和保存它

这是我在 VSCode 打开时看到的:

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)