Gab*_*abe 59
将您的资源添加到项目属性中的项目...(您做了)
那很简单......
var zipFile = MyNamespace.Properties.Resources.My_Zip_File;
Run Code Online (Sandbox Code Playgroud)
Visual Studio社区2015回答:
现在可以以编程方式访问该文件.调试时以及将progam作为最终发布安装时,路径和文件是程序集的一部分.它与使用绝对路径相比毫不逊色.示例C#header:
using System.IO;
using System.Reflection;
Run Code Online (Sandbox Code Playgroud)
示例C#代码:
String strAppPath = Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
String strFilePath = Path.Combine(strAppPath, "Resources");
String strFullFilename = Path.Combine(strFilePath, "My_Zip_File.zip");
Run Code Online (Sandbox Code Playgroud)
`例如,我们可以将文件读作Stream,我们也可以使用strFullFileName打开文件.