Can I embed other files in a DLL?

前端 未结 4 1887
轮回少年
轮回少年 2020-12-16 15:09

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, ch

4条回答
  •  天命终不由人
    2020-12-16 15:32

    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");
    

    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.

提交回复
热议问题