Hello all,

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.

Regards,

Charles.

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");

Anyone have any suggestions?

Is it at all possible to edit and make changes to the Appname.config file? (Using ConfigurationManager that is)

Regards.

As far as I am aware you cannot alter this file from inside the application to which it belongs. You would be able to use a separate XML config file though, but you would obviously need to write the parsing algorithm yourself.

This article has been dead for over six months. Start a new discussion instead.