xml file embedded: can´t save changes
-
Hi, i have a xml file embedded in my project resources. I can read it but i can´t save changes on it, check code bellow
// class_helper.ResourcesXml_Login is the xml file!
DataSet ds = new DataSet();
ds.ReadXml(Class_Helper.ResourceXml_login, XmlReadMode.ReadSchema);
DataGridView_Administrator.DataSource = ds.Tables[0];
DataRow DataRow_user = ds.Tables[0].NewRow();
DataRow_user["id"] = 10;
DataRow_user["f_name"] = ToolStripTextBox_FName.Text;
DataRow_user["l_name"] = ToolStripTextBox_LName.Text;
DataRow_user["username"] = ToolStripTextBox_Username.Text;
DataRow_user["password"] = ToolStripTextBox_Password.Text;
DataRow_user["role"] = ToolStripComboBox_Role.Text;
ds.Tables[0].Rows.Add(DataRow_user);
ds.WriteXml(Class_Helper.ResourceXml_login,XmlWriteMode.WriteSchema);
DataGridView_Administrator.DataSource = ds.Tables[0];i can save changes if i use the path way you know?! but i want this way and i really dont know where the codes goes wrong :doh:
nelsonpaixao@yahoo.com.br trying to help & get help
-
Hi, i have a xml file embedded in my project resources. I can read it but i can´t save changes on it, check code bellow
// class_helper.ResourcesXml_Login is the xml file!
DataSet ds = new DataSet();
ds.ReadXml(Class_Helper.ResourceXml_login, XmlReadMode.ReadSchema);
DataGridView_Administrator.DataSource = ds.Tables[0];
DataRow DataRow_user = ds.Tables[0].NewRow();
DataRow_user["id"] = 10;
DataRow_user["f_name"] = ToolStripTextBox_FName.Text;
DataRow_user["l_name"] = ToolStripTextBox_LName.Text;
DataRow_user["username"] = ToolStripTextBox_Username.Text;
DataRow_user["password"] = ToolStripTextBox_Password.Text;
DataRow_user["role"] = ToolStripComboBox_Role.Text;
ds.Tables[0].Rows.Add(DataRow_user);
ds.WriteXml(Class_Helper.ResourceXml_login,XmlWriteMode.WriteSchema);
DataGridView_Administrator.DataSource = ds.Tables[0];i can save changes if i use the path way you know?! but i want this way and i really dont know where the codes goes wrong :doh:
nelsonpaixao@yahoo.com.br trying to help & get help
Of course you can't do this. First of all, resources are Read Only. Second, in order to save those changes, the .EXE file cannot be running because a running .EXE's file is locked by the system. So, in order to update the resource, you have to NOT be running the code.
nelsonpaixao wrote:
but i want this way and i really dont know where the codes goes wrong
It's not the code that's going wrong, but your entire concept. You simply cannot do what you want.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Of course you can't do this. First of all, resources are Read Only. Second, in order to save those changes, the .EXE file cannot be running because a running .EXE's file is locked by the system. So, in order to update the resource, you have to NOT be running the code.
nelsonpaixao wrote:
but i want this way and i really dont know where the codes goes wrong
It's not the code that's going wrong, but your entire concept. You simply cannot do what you want.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008thanks, i didn´t know that. :) i will use the path method.
nelsonpaixao@yahoo.com.br trying to help & get help