Home All Groups Group Topic Archive Search About

Is there a way to see if a file is in use?

Author
20 Apr 2006 7:55 PM
Anthony Ho
Hi,

I use the following:
FileOpen(taskmgrfile, "C:\trend.csv", OpenMode.Random, OpenAccess.Read,
OpenShare.LockRead)
to open a file, but it returns err.number 75 "The process cannot access the
file "C:\trend.csv" because it is being used by another process."

Is there a way to check if the file is in use before I try to open it?

thanks in advance!

Author
20 Apr 2006 8:00 PM
zacks
Why not put your FileOpen in a Try/Catch block and trap that particular
error?
Author
20 Apr 2006 8:10 PM
Anthony Ho
is there a more positive way?

<za***@construction-imaging.com> wrote in message
Show quoteHide quote
news:1145563225.438363.102600@v46g2000cwv.googlegroups.com...
> Why not put your FileOpen in a Try/Catch block and trap that particular
> error?
>
Author
20 Apr 2006 8:44 PM
Gordowey
>is there a more positive way?

<z***@construction-imaging.com> wrote in message


news:1145563225.438363.102600@v46g2000cwv.googlegroups.com...


>- Hide quoted text -
-> Show quoted text -

> Why not put your FileOpen in a Try/Catch block and trap that particular
> error?


I also think that Try/catch is the way to doi..

see here ..maybe can helps you
http://www.swapcode.com/domdoc/page/lscode003.html

regards, Al
Author
20 Apr 2006 8:52 PM
zacks
Well, you could write your own IsOpen method for the File class, but it
would probably determine if the file is already open by doing the same
thing, ie, try doing a FileOpen in a Try/Catch and catch the already
open exception.
Author
21 Apr 2006 12:48 AM
Bob Lehmann
>> is there a more positive way?
What the heck does that mean?

Are there self-esteem issues with try/catch?

Bob Lehmann

Show quoteHide quote
"Anthony Ho" <wing***@addr.com> wrote in message
news:OeR0BaLZGHA.1228@TK2MSFTNGP02.phx.gbl...
>
> is there a more positive way?
>
> <za***@construction-imaging.com> wrote in message
> news:1145563225.438363.102600@v46g2000cwv.googlegroups.com...
> > Why not put your FileOpen in a Try/Catch block and trap that particular
> > error?
> >
>
>
Author
21 Apr 2006 6:42 AM
Stephany Young
Of course there is Bob!!!!!!!!!!

Didn't you know that constantly trying and failing is one of the main causes
of low self-esteem?



Show quoteHide quote
"Bob Lehmann" <nospam@dontbotherme.zzz> wrote in message
news:OYPdm0NZGHA.2136@TK2MSFTNGP05.phx.gbl...
>>> is there a more positive way?
> What the heck does that mean?
>
> Are there self-esteem issues with try/catch?
>
> Bob Lehmann
>
> "Anthony Ho" <wing***@addr.com> wrote in message
> news:OeR0BaLZGHA.1228@TK2MSFTNGP02.phx.gbl...
>>
>> is there a more positive way?
>>
>> <za***@construction-imaging.com> wrote in message
>> news:1145563225.438363.102600@v46g2000cwv.googlegroups.com...
>> > Why not put your FileOpen in a Try/Catch block and trap that particular
>> > error?
>> >
>>
>>
>
>