2013-06-27, 05:19
(2013-06-26, 18:41)m.savazzi Wrote: This is driving me nuts.
Sometimes I get an error at runtime when the program tries to save the language_strings.log or the AdvancedSettings.xml file.
If anyone has an idea is more than welcome!
I just finished looking at the code paths for saving AdvancedSettings.xml. The file is persisted after EVERY small change to the data.
What COULD be going on is some other process watching the NTFS journal (or a directory change notification) and then opening the file behind our back.
(Like an Anti/Virus program.)
Look at all of those modules SaveSetup routines. They each make ~2-5 separate calls to the AdvacnedSettings class. The AdvancedSettings class saves the XML file for EACH of those methods. Ugh.
There are a couple of alternatives to this general dilemma:
* Refactor AdvancedSettings API contract so that it isn't nearly so Save happy.
This would be extra nice because the Save constructs the XML document from scratch each time it gets called.
* Alter the if File.Exists() then File.Delete() logic to catching an IOException if the Delete() fails, Thread.Sleep() (say 50ms or so) and try again 2-3 more times.
If you still fail after that then just re-throw the exception.
I haven't looked at the language_string case yet.
Bill