Just how to look for documents lock?

Exists any kind of means to examine whether a documents is secured without making use of a try/catch block?

Now, the only means I recognize of is to simply open the documents and also capture any kind of System.IO.IOException.

0
2019-05-03 23:59:13
Source Share
Answers: 2

Then in between both lines, an additional procedure can conveniently lock the documents, offering you the very same trouble you were attempting to stay clear of to start with : exemptions.

Nonetheless, in this manner, you would certainly recognize that the trouble is short-lived, and also to retry later on. (E.g., you can write a string that, if running into a lock while attempting to write, maintains retrying till the lock is gone.)

The IOException, on the various other hand, is not on its own details sufficient that securing is the source of the IO failing. There can be factors that aren't short-lived.

0
2019-12-03 04:42:23
Source

No, however, and also if you think of it, that details would certainly wear anyhow given that the documents can come to be secured the really next 2nd (read : brief time frame ).

Why especially do you require to recognize if the documents is secured anyhow? Recognizing that could offer us a few other means of offering you excellent suggestions.

If your code would certainly resemble this :

if not locked then
    open and update file

After that in between both lines, an additional procedure can conveniently lock the documents, offering you the very same trouble you were attempting to stay clear of to start with : exemptions.

0
2019-05-07 17:22:41
Source