在dll中打包xml文件,c# [英] pack xml files inside dll,c#

查看:219
本文介绍了在dll中打包xml文件,c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.NET C#2.0项目,它涉及许多.xml文件,当我将我的项目移植到另一个位置或分发文件时,我需要这些文件。我目前不想把它作为一个setup.exe文件。我想要独立目前我已经把它们全部放在我的项目中的一个文件夹FILES中。所以我想知道的是


  1. 我可以将所有这些XML文件打包到一个dll里面,这样它的安全性和便携性?如果是这样做?

  2. 当我构建程序时,不会复制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

  1. Can i pack all these XML files inside a dll, so that it's secure and portable? If so how to do it?
  2. 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屋!

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