Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pack xml files inside dll,c#

Tags:

c#

dll

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?
like image 218
Anirudh Goel Avatar asked Mar 18 '09 11:03

Anirudh Goel


1 Answers

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).

like image 158
Marc Gravell Avatar answered Sep 23 '22 21:09

Marc Gravell