我可以在 DLL 中嵌入其他文件吗? [英] Can I embed other files in a DLL?

查看:25
本文介绍了我可以在 DLL 中嵌入其他文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过 API 为另一个应用程序编写插件.插件分发了一个 DLL.是否可以在 DLL 文件中嵌入其他文件,如 pdf、图像、chm 帮助文件等...我希望能够为我的插件提供文档,但我仍然希望保留分发插件的能力- 作为单个文件,用户可以直接拖放到应用程序上进行安装.

I'm writing a plug-in for another application through an API. The plug-ins are distributed a DLLs. Is it possible to embed other files in the DLL file like pdfs, images, chm help files etc... I want to be able to provide documentation with my plug-in but I'd still like to retain the ability to distribute the plug-in as a single file the user can just drag and drop onto the application to install.

推荐答案

当然,您可以在 DLL 中嵌入资源.然后在运行时你只需要做:

Sure, you can embed a resource in your DLL. Then at runtime you just do:

Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("com.stackoverflow.plugin.example.Foo.pdf");

这会给你一个流到你的 DLL 中嵌入的 Foo.pdf 文件.请注意,资源名称必须由您从中调用方法的类型的命名空间限定范围.

This would give you a stream to the Foo.pdf file embedded in your DLL. Pay attention to the fact that the resource name has to be scoped by the namespace of the type from which you're invoking the method.

这篇关于我可以在 DLL 中嵌入其他文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆