I have 2 processes writing some info to the same file. It's a small file the contents of which get replaced.
I'm trying to figure out a reliable way of detecting the file is in use so I Can abort or retry or whatever.
I create a FileStream using Mode=Create, Access=Write, Share=None
The problem is that this will throw an IOException if the file is in use. But I can't tell that this is the problem. It could be any other FileException. The only way I could tell is to look at the exception message.
Any suggestions? Surely there must be a simple way. Haven't turned anything by googling so maybe not.
I'm trying to figure out a reliable way of detecting the file is in use so I Can abort or retry or whatever.
I create a FileStream using Mode=Create, Access=Write, Share=None
The problem is that this will throw an IOException if the file is in use. But I can't tell that this is the problem. It could be any other FileException. The only way I could tell is to look at the exception message.
Any suggestions? Surely there must be a simple way. Haven't turned anything by googling so maybe not.
Comment