当然,您可以在DLL中嵌入资源.然后在运行时你只需:
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("com.stackoverflow.plugin.example.Foo.pdf");
Run Code Online (Sandbox Code Playgroud)
这将为您提供Foo.pdf嵌入DLL中的文件的流.请注意资源名称必须由您调用该方法的类型的命名空间确定范围.
是的,你可以这么做。
将资源文件添加到您的项目中。在 Visual Studio 中打开资源文件,然后单击“插入资源”。您可以选择不同类型的资源,包括外部文件。
Visual Studio 将为您生成代码,以便您可以在运行时通过标识符从文件名检索文件作为字节数组Resources。