C# Programming
11-06-2009, 10:41 PM
I need to use an incremental counter, by means of retrieving and updating a value stored in a text file
I know how to use the StreamWriter and the StreamReader classes but what I need to do is to read an int value from a text file, then increment the value by one and write it back to the file.
Is there a way to place a lock in the file while doing both operations? The reason for that is to avoid multiple concurency.
Also, how can the file be checked if it is locked?
Thanks,
CBenac
I know how to use the StreamWriter and the StreamReader classes but what I need to do is to read an int value from a text file, then increment the value by one and write it back to the file.
Is there a way to place a lock in the file while doing both operations? The reason for that is to avoid multiple concurency.
Also, how can the file be checked if it is locked?
Thanks,
CBenac