Re: Preserve State
- From: Martijn Mulder <i@m>
- Date: Sun, 30 Sep 2007 21:57:57 +0200
In a simple desktop application, when the user starts my program again, I want her to find things just as she left them last time. What is a simple straightforward way to implement such persistence?
Look at the MSDN documentation for the System.Configuration.ApplicationSettingsBase class and the See Also Reference links. There are alot of links that describe how.
Also
http://msdn2.microsoft.com/en-us/library/0zszyc6e.aspx
When I go through the steps described in the link above and implement an ApplicationSettingsBase-object for my Form, the system writes out a file 'user.config' somewhere deep in C:\Documents and Settings\UserName\Local Settings\Application Data\... This file contains xml. When I (deliberatly) corrupt this file I can no longer read from it or write to it. The exception it raises can by caught with two try{}catch{} blocks, one for reading it and one for writing to it. But than the whole mechanism is vanished. I cannot read from the corrupt file, I cannot write to the corrupt file and I cannot (untill now) replace it with a new and valid user.config file.
Is there a safe way to start with a clean ***, once the user.config file is corrupted?
.
- Follow-Ups:
- Re: Preserve State
- From: Doug Semler
- Re: Preserve State
- References:
- Preserve State
- From: Martijn Mulder
- Re: Preserve State
- From: Doug Semler
- Preserve State
- Prev by Date: Re: Common Context menu for two controls
- Next by Date: Re: Regex issue
- Previous by thread: Re: Preserve State
- Next by thread: Re: Preserve State
- Index(es):