I have a very simple web application that have to read and write in a text file. Basically, for each request the app looks for a specific line, if the line doesn't exists... it creates it. Not to mention that that operation has to be done in atomic fashion.
What is the best way to lock the file so only one http request can use at the time? And if possible, a way that doesn't throw exceptions when the file is locked :P
Define a static readonly Object
in the page code and use it for do lock()
?
Using System.IO.FileStream.Synchronized()
?
Any other?
Many thanks.