Home All Groups Group Topic Archive Search About

Config file deletion on Close() with System.Configuration

Author
12 Apr 2007 8:02 AM
Jouan Amate
Hi,

Here is my code

Code:

class ConfigFile
{
    public void AddToConfig(string drive, string path)
    {
        System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
        config.AppSettings.Settings.Add(drive, path);
        config.Save();
    }
}



When I call this method, the file is created and filled correctly.
The file is valid all along the program but is deleted automatically
when the program closes.
The only way I found to prevent that is setting the file in read-only
before the application closure. Not really clean though...

How can I manage to keep the file after closure?

Thanks

AddThis Social Bookmark Button