I want to open a file for read in exclusive mode, and if the file is already opened by some process/thread else, I want to receive an exception. I tried the following code,
FileShare.None will only work if another process has also opened the file without allowing it to be shared for reads.
Programs such as Notepad and Visual Studio do not lock text files.