i want to embed a xml file to a resource file in my project,whenever i need the file i must get it from resource and use it,how to do this and i want to modify the contents of the xml file depending upon my requirements.how to do this
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you add the XML file to a Visual Studio project and, in the Property window for it, select Build Action: Embedded resource, the file will be embedded into the build output artifact for that project.
To access it from code, use something like:
If the resource you’re loading is embedded in your own assembly, you can do something like
Assembly.GetExecutingAssembly()to achieve what I listed asLoadYourAssemblyContainingTheResource()above, or possiblytypeof(SomeTypeInYourResourceAssembly).AssemblyIt’s unclear what you mean by “want to modify the contents” – you cannot modify the resource inside the assembly at run-time, but whenever you change the XML file and recompile, the new version will be embedded.