Re: How to check if a file is locked?
- From: "Greg Young" <druckdruckREMOVEgoose@xxxxxxxxxxx>
- Date: Thu, 6 Jul 2006 21:22:29 -0400
I am not sure of the relevance of the first post on here perhaps it went to
the wrong thread?
For file locking you would have to handle this exception anyways. The file
may not be locked when you check it but could then be locked when you try to
go to open it. The checking would however remove many instances of ther
exception. That said in this case your best best is to trap the exception as
there is no other good way of doing this, you could also use pinvoke
(CreateFile) to avoid having the exception thrown but the exception is
really not that expensive. You should then wait a little bit before trying
again if thats your overall goal.
Cheers,
Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung
"cmay" <cmay@xxxxxxxxxxxxxx> wrote in message
news:1152216505.981826.103000@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
The only examples I have seen on how to check if a file is locked is to
try to open it a catch an exception.
MS has stated that you should never use error trapping in this manner.
Is there no other way to identify if a file is locked w/o trapping an
exception?
.
- Follow-Ups:
- Re: How to check if a file is locked?
- From: Chris Dunaway
- Re: How to check if a file is locked?
- From: cmay
- Re: How to check if a file is locked?
- References:
- How to check if a file is locked?
- From: cmay
- How to check if a file is locked?
- Prev by Date: Re: Mainstream Apps using DotNet
- Next by Date: problems by sending email with c# and web.config in a webserver Win 2003
- Previous by thread: Re: How to check if a file is locked?
- Next by thread: Re: How to check if a file is locked?
- Index(es):
Relevant Pages
|