在dll中打包xml文件,c# [英] pack xml files inside dll,c#
问题描述
- 我可以将所有这些XML文件打包到一个dll里面,这样它的安全性和便携性?如果是这样做?
- 当我构建程序时,不会复制FILES文件夹。
您可以将xml文件标记为资源,它们将被打包在程序集中。只需将构建动作设置为嵌入式资源即可。或者,使用资源文件(resx),并将xml文件拖放到resx设计器上,并为您完成所有操作(包括提供访问方法以获取数据)。
I have a .NET C# 2.0 Project and it refers to many .xml files, i'd need these files when i port my project to another location or distribute it. I'm currently not interested in making it as a setup.exe file. I want to to be standalone. currently i've got all of them in a folder "FILES" within my project. So what i want to know is
- Can i pack all these XML files inside a dll, so that it's secure and portable? If so how to do it?
- When i build the program the FILES folder is not copied. How can i make it copy it as well?
You can mark the xml files as resources, and they will be packaged inside the assembly. Just set the "build action" to "embedded resource". Alternatively, use a resource file (resx), and drag the xml files onto the resx designer, and it'll do everything for you (including providing access methods to get the data back out).
这篇关于在dll中打包xml文件,c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!