Hy there. I want to make an application that can modify any configuration file. I open a file dialog, select the file, populate some boxes with the information from the file, and lastly have a button "save information". Can I do this?
private void metroButton1_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "Config Files|*.config";
openFileDialog1.Title = "Slectează un fișier de configurări";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = openFileDialog1.FileName;
filename = openFileDialog1.FileName;
}
}
string appName = "AdministrareRetele.exe";
Configuration config = ConfigurationManager.OpenExeConfiguration(appName);
ConnectionStringsSection section = config.GetSection("connectionStrings") as ConnectionStringsSection;
I don't know what to put at "ConfigurationManager"...
Thank you!
EDIT
I can get all the information I want from the configuration file of the CURRENT application. But I want to be able to get and modify info for other application.
Current scenario:
I have 2 files: App.exe and app.config in SAME folder. I write this code:
string appName = "App.exe";
Configuration config = ConfigurationManager.OpenExeConfiguration(appName);
ConnectionStringsSection section = config.GetSection("blabla") as ConnectionStringsSection;
and I get information about my current app (App.exe)
Now, I need to modify "OpenExeConfiguration" method or write a new one that will read a config file that i give as a parameter..
Hope, this time made it clear