在 Windows 程序中打开嵌入文件

Open embedded file in Windows program

我在我的 C# 程序中将一个文件放在我的资源上。我尝试在特定应用程序中打开它,但不明白如何打开它。

我已经看到了:.NET: Open files, which are embedded in a resource file

还有这个:

我需要在 Revit.exe

中打开“TEST.rvt”(Autodesk Revit 文件),这是一个嵌入式资源

我不想将文件复制到我的系统,因此无法设置 Copy to Output Directory 选项。

可能吗?

我没有 Revit,所以我不知道这是否可行。但如果不设置 Copy to Output Directory,以下内容似乎适用于记事本中的 .txt 文件。

string textFile = Properties.Resources.Testfile;

Process process = new Process();
process.StartInfo.FileName = "Notepad.exe"; // Set this to Revit.exe or whatever name it has
process.StartInfo.Arguments = textFile;
process.Start();

Properties.Resources.Testfile是项目中嵌入的.txt文件。

我不知道 .rvt 文件是什么样的,所以我不知道这是否能正常工作。

我在互联网上的许多帖子上都看到了,这似乎是不可能的。我会将我的 .rvt 复制到一个临时文件夹中,并在使用它们之前将其删除。

为了复制它们,我使用了 this thread

中的解决方案