Windows Develop Bookmark and Share   
 index > Windows Forms General > Application Configuration Files
 

Application Configuration Files

Is there any easy way (or has anyone created a class) to edit and update configuration settings for a DIFFERENT application to the one that is running. I am creating a management application that needs to be able to update the configuration file (.exe.config) of the application it is managing. I will only be editing about 5 keys. Can this be done through xml serialization? If so how? I have had a go with various ways but all were fruitless. Any ideas welcome.

David Legg
MigrationUser 1  Friday, April 09, 2004 1:33 PM
Yep, the easiest way is to just load the config file into an XMLDocument object, make whatever changes you need, then save it back out. The changes will take effect the next time the app starts. 

With XMLDocument, you can add, update, and delete items wherever you need to in the configuration. Pretty straightforward really, as long as you know how to use the System.Xml namespace.

There's also a configuration application block you can use. And you can use custom configuration sections, which is cool but may be overkill.

I'm not sure what you mean by using XML serialization. That's a way of persisting objects as XML.

Don
MigrationUser 1  Friday, April 09, 2004 2:04 PM
can you give me an example of this? I am not that familiar with the system.xml namespace. I will give a sceneario, could you post some code to do it?



<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="autostarthttp" value="yes" />
<add key="autostartftp" value="yes" />
<add key="FTPRoot" value="c:\wwwroot" />
<add key="HTTPConfig" value="C:\wwwdata\config" />
<add key="HTTPLogs" value="C:\wwwdata\logs" />
</appSettings>
</configuration>



Sceneario:
I want to put the ftp root value into a textbox. after editing it and clicking a button edit the value stored in the config file. can you post some sample code to do this?

David Legg
MigrationUser 1  Friday, April 09, 2004 2:11 PM
I've managed to do it using XML serialization. I took another look at my code and found where I went wrong. I will post my component somewhere for anyone who is interested in using it.

David Legg
MigrationUser 1  Sunday, April 11, 2004 5:29 AM

You can use google to search for other answers

Custom Search

More Threads

• How do I animate a button click from code?
• Container image drag&drop
• Windows Forms with Web Like Interfaces?
• Cd-Writing
• SplitContainer and UserControls
• Expanding and collapsing region control
• Windows MDI Form, DragDrop
• Form Loaded Event
• Adding Color to CheckedListBox
• vb.net(2005) TableLayoutPanel