G
Guest
I have embedded resource called Settings.xml. I'm able to read the resource but how can I write data to the resource. The code for read operation follows:
private XmlDocument m_doc = new XmlDocument();
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
System.IO.Stream stream = a.GetManifestResourceStream(this.GetType(),"Settings.xml");
if(!(null==stream))
{
System.IO.StreamReader rdr = new StreamReader(stream);
m_doc.Load(rdr);
stream.Close();
rdr.Close();
}
Now, if I make changes to m_doc and want to save them to embedded resource, I try like this:
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
Stream stream = a.GetManifestResourceStream(this.GetType(),"Settings.xml");
m_doc.Save(stream);
stream.Close();
This raises exception, however: "Stream is not writable." What am I doing wrong?
private XmlDocument m_doc = new XmlDocument();
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
System.IO.Stream stream = a.GetManifestResourceStream(this.GetType(),"Settings.xml");
if(!(null==stream))
{
System.IO.StreamReader rdr = new StreamReader(stream);
m_doc.Load(rdr);
stream.Close();
rdr.Close();
}
Now, if I make changes to m_doc and want to save them to embedded resource, I try like this:
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
Stream stream = a.GetManifestResourceStream(this.GetType(),"Settings.xml");
m_doc.Save(stream);
stream.Close();
This raises exception, however: "Stream is not writable." What am I doing wrong?