Auto increment Id's in .net
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 gen开发者_高级运维erated. 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?
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
If you don't want to use a database for this, you could just store the last used ID in your application configuration settings.
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.
how about keeping a file with just the recently used number it it
精彩评论