Click here to Skip to main content
15,881,866 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have added a xml as a project resource (the ones that are been added from Project->Project Properties->Resources Tab->AddResource->AddExistingFile-> Select MyResource.xml)

I have been displaying the content of this file as it was a regular XDocument

C#
XDocument _xDoc = XDocument.Parse(MyApp.Properties.Resources.MyResource);


Now if I have added new elements (or remove old ones) from the _xDoc I want to record those changes also in MyResource.xml file.
Normally I will do it with :

C#
public  void  SaveMofifiedDoc(XElement  _new){
 _xDoc.Element(TAG).Add( _new);
_xDoc.Save("DocPath");
}

I am looking for something like:

C#
public  void  SaveMofifiedDoc(XElement _new) {
 _xDoc.Element(TAG).Add( _new);
MyApp.Properties.Resources.MyResource.Save(_xDoc)
}


I googled and I see this is not that easy , maybe I have to use streams but I didn't saw any example that suits what I want.
Posted
Updated 22-Sep-15 3:55am
v6
Comments
sreeyush sudhakaran 22-Sep-15 5:12am    
Did you mean to SaveAs/Save Xml file in resources directory after modifying Xml from your source code?
Kinna-10626331 22-Sep-15 5:18am    
Yes I want to save the changes (whathever they are) on Properties.Resources.MyResource . Then next time I have to parse this resource changes made will be there. I want to access to this xml as a project resource and be able to modify it and save changes done.

1 solution

Project resources are not meant to be modified at runtime and saved back ; because such resources are integrated to the file during compilation.

If you want to modify the xml file at runtime and save the changes, then stick with an xml file of its own, that you will be able to read and write at any time.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900