I’m working on a GUI that is able to manipulate xml files through a datagridview and have it saved to a destination of the user’s choice. This program also has a .exe.config file in which I would also like to be able to freely edit inside a datagridview, since it’s a lot more convenient than having the user manually going in to the file and changing the values accordingly.
I’ve tried declaring a dataset, and I intially thought that a .exe.config file was just an xml file, but this code does not work:
dataSet1.ReadXml(configpath);
bindingSource1.DataSource = dataSet1.Tables[0];
dataGridView1.DataSource = bindingSource1;
The datagridview is empty when I ran it and i confirmed that the filepath was correct and there was no exception when i debugged the code, whereas for the other xml files I open in the GUI work perfectly fine with the data displayed. Maybe readxml() only supports.. legit xml files rather than xml configuration files? I tried googling and looking for some answers, but all I got were threads related to changing the settings by manually accessing the xml file and changing the values (stuff I already know). I’m looking to be able to have the user do what they want to do with the data and then save it. The .exe.config settings may just as well be for another program, but it is essentially an xml configuration file. I figured there wasn’t much on the web for this particular problem because settings are generally static and if they are changed, it’s pretty easy to do manually.
To sum up,
I’m looking for a method to be able to open any .exe.config file, display it in a datagridview, allow the user to be able to manipulate the data values inside, and then save the file, overwriting the previous data settings.
Any help is appreciated.
Thank you in advance!
- tf.rz (.NET 3.5 SP1, Visual Studio 2008 C#)
EDIT: I will upload a working example of an xml file I created: I kind of want the program to be able to navigate to a .exe.config file, then open it and have it displayed like this where the setting names are the columns and the values are in the cells of the datagridview. Unfortunately I am not at my home computer to be able to do this.
This is what I used to load up and manipulate a config file. You may want to change the
loadAppSettingsandloadConnStringsmethods to suit your needs.