My application uses a settings file settings.txt to save the currently set values of the controls placed on a form. Each time the application starts this settings file is referred to load the settings into the application window.
I use a function named void SaveSetting(string SettingName) with some switch-cases to save the settings. Is it possible to develop a similar function named void RemoveSetting(string SettingName) which will remove the specified setting from settings.txt file altogether???
Here I don’t want to remove the get and set values from settings.cs file but I need to delete the entry from settings.txt file without corrupting the file.
Also I don’t want to set the value null or zero to that particular control (’cause its causing an error at run-time).
Is it possible to remove an entry entirely from the settings file???
Language: C#
Platform: Windows
IDE: Visual Studio 2008
.NET framework: 3.5
Thanks.
If the settings file is small, you could simply completely overwrite it each time you want to save any change (adding/removing/changing an entry). Then you don’t have to worry about breaking the format.
Alternately, if you want to only append to the end of the settings file, you could define a new type of entry that removes an old entry.