I have a puzzling dilemma and can't determine the cause because it occurs so infrequently.
I have an ini file located under C:\ProgramData\Aztech\SnS and within the ini file are configuration settings like server name and shared path. My application uses this to make a connection to the SQL 2012 Express database.
The ini file in extremely rare occasions is reset, totally blank and the user cannot use the application until I repopulate the ini file. this has occurred on multiple sites and different machines, and since these sites I do not have as IT support clients I cannot determine what is happening at the time this occurs. generally they find it is like this in the morning when they switch the system on.
Does anyone have any idea what may be causing this?
Each time you call a function that modifies the INI file, the entire file is loaded into memory, modified and then written back out. It's not (in any way) efficient but it was the easiest way to implement it. If you're only reading from the INI file then it doesn't get modified and there shouldn't be any opportunity for corruption.
If you want a hedge against this type of failure you can use the FileSys plugin to make a backup copy of the INI file at key points (after you save the database connection info) and if the read of that info ever fails you can just copy the backup INI file over the corrupted version and carry on.