Checking Resource Status of a File

J

Jason E. Trout

Is there anyway in VB.NET to test a file to see if another resource is
currently using it? Basically, through an automated process, a file is
opened (and then closed with user intervention); however, I need to be
able to carry on a process after that fact, so I'd like to poll the
file until the resource has been given up. Any advice would be greatly
appreciated.


Thank You,
Jason E. Trout
(e-mail address removed)
 
H

Herfried K. Wagner [MVP]

* (e-mail address removed) (Jason E. Trout) scripsit:
Is there anyway in VB.NET to test a file to see if another resource is
currently using it? Basically, through an automated process, a file is
opened (and then closed with user intervention); however, I need to be
able to carry on a process after that fact, so I'd like to poll the
file until the resource has been given up.

The only way to do that I am aware of is to try to open the file for
shared reading and catch an exception if the file cannot be opened in
this mode.
 
C

Cor Ligthert

Hi Jason,

In addition to Herfried,

When it is an Access file than do not what is everywhere told (as well by
me) for a database and to close it every time after you did a dataadapter
fill or dataadapter update. Keep it open all the time, the same you should
do in situations for other files in my opinion which are not freeed to use
by other users.

I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top