简体   繁体   English

将xml嵌入自定义控件

[英]embed xml in custom controls

i create a custom Control and using the XML file now i need to have just one dll file to use that to another project can you help me to embed xml file to my custom control project? 我创建一个自定义控件并使用XML文件,现在我只需要一个dll文件即可将其用于另一个项目,您能帮我将xml文件嵌入到我的自定义控件项目中吗?
my programming language is c#.net 我的编程语言是c#.net

If you are using Visual Studio (My version is 2008, if you have 2010, this might be slightly different.) 如果您使用的是Visual Studio(我的版本是2008,如果是2010,则可能略有不同。)

  1. Open properties for your DLL project. 打开您的DLL项目的属性。
  2. Click the Resources tab. 单击资源选项卡。
  3. Click the blue link (if there is one to add resources to your DLL). 单击蓝色链接(如果有,可将资源添加到DLL)。
  4. Top Left with the little down arrow choose files. 左上方带有小向下箭头选择文件。
  5. Click Add Resource, find your file and add it. 单击添加资源,找到您的文件并将其添加。 Give it a name like XmlFile with no dots, this is your handle to the file. 给它一个类似XmlFile的名称,不XmlFile ,这是您处理文件的方式。
  6. Save and Close Properties for the DLL. 保存并关闭DLL的属性。

Then somewhere in your project you will use this line, or something like it to access your file. 然后,在项目中的某处,您将使用此行或类似的行来访问文件。

XElement root = XElement.Parse(Properties.Resources.XmlFile);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM