Martijn Mulder said:
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 sheet, once the user.config file
is corrupted?
Well, there's a reason that the file is buried where it is. The file is
maintained by the framework...there's really no reason for you to be mucking
with it...and in fact can be located in a differnt location based on whether
it's click-once, roaming profile, even version number of the app. Let the
framework handle this file and you should be fine...
There is a Reset() function on applicationSettingsBase that you could try
calling but I think that still tries to call a Reload(), which will cause an
exception if the file is corrupt.
ANY data file that has corrupted data will cause unexpected results, whether
it's an XML file that the framework is maintaining or some binary file that
you are writing.
--
Doug Semler, MCPD
a.a. #705, BAAWA. EAC Guardian of the Horn of the IPU (pbuhh).
The answer is 42; DNRC o-
Gur Hfrarg unf orpbzr fb shyy bs penc gurfr qnlf, abbar rira
erpbtavmrf fvzcyr guvatf yvxr ebg13 nalzber. Fnq, vfa'g vg?