views:

252

answers:

4

We need to store xml file in file system. The xml files should have a uniqueId ranging from (00000001 to 99999999) Is there a way to auto increment the ids for any new xml generated. The xml are stored in folder structure which is complex. I tried taking the count of xml files that this seems to be a slow operation. The application is developed in c#.net Can anyone suggest any other way of persisting the data. Database seems to be one of the opetion but storing a value in a table with just one column doesn't sound like a great idea. can anyone suggest other ways?

+5  A: 

I am assuming your application is not stateful, meaning it will be started and stopped several times.

I would consider using an Application Setting which in a standard .NET project is an option available to you that is read/write. The value can be strongly typed and will be stored in the application configuration file.

Examples: http://msdn.microsoft.com/en-us/library/aa730869%28VS.80%29.aspx

keithwarren7
AHHHHHHHHH you beat me too it! You get my vote
Zoidberg
The application which stores the xml us a WCF service which has web.config. I am not sure if i can set any value in Web.config file from code. Could you please put some light on this?
Balaji
I am getting the following error "The current configuration system does not support user-scoped settings".Since my application is WCF application it runs under ASP.Net user setting are not supported.When i change the scope to application i am not able to store the last incremented value.Can anyone suggest what can be done in this case?
Balaji
+1  A: 

how about keeping a file with just the recently used number it it

Am
+2  A: 

Persist the last used value in a properties file that you might already be using to persist a lot of other initial settings you might do.

Jass
+3  A: 

If you don't want to use a database for this, you could just store the last used ID in your application configuration settings.

Reed Copsey