I'm writing a small "robot" application that has to process a list of sequentially numbered MDB files. This has to be done between different executions, ie: today I process files 1,2 and 3. Tomorrow I might process 4 and 5. It's totally random, but sequential.
My question is this: how can I keep track of the files? They are named thus: TFXXXX.mdb
where XXXX is their number.
My first approach was to save a "counter" variable in the appSettings field in the config file but when I update the correct field, the changes are not applied to the actual XML file, they are stored in Cache.
I've tried to find a solution online but no luck. I've read the entire ConfigurationManager class from MSDN.
Or can anyone suggest a completely different approach?
PS: I'm using a configuration file because that counter isn't the only thing that has to be read at runtime.
Some code I've tried:
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); AppSettingsSection appSettings = (AppSettingsSection)config.GetSection("appSettings"); appSettings.Settings.Clear(); string newcounter = "123"; config.AppSettings.Settings.Add("MDBCounter", newcounter); config.Save(); ConfigurationManager.RefreshSection("appSettings");