views:

97

answers:

1

Are there any built in methods in System.Configuration that would allow one to backup the currently running apps XXX.exe.config file. Or if not, how would one retrieve the current applications config file name for backup.

+2  A: 

You should be able to do this using the System.Configuration.ConfigurationManager class.

The OpenMappedConfiguration method can be used to open a instance of the System.Configuration.Configuration type based on your app/web config (or any other file in the right format, so someone else's app/web config). Then the Configuration type has a Save method and a SaveAs method.

Can't say that I've used them to do exactly what you want but (to speak to @StingyJack's comment) I have used them in a Installer subtype (a ProjectInstaller for a service).

Hamish Smith