File in use detection

  • Thread starter Thread starter Landley
  • Start date Start date
L

Landley

How do detect whether a file is in use, and if it is in use, by who / what
process?

L.
 
Landley,

Until now we did not see a better solution in this newsgroup, than to check
if it exist using "file.exist" and than to set the open (construct) in a try
and catch block, which is itself in a do until loop and than to use a
threading.thread.sleep in the catch block of that when it is not readable.

I hope this helps?

Cor
 
Mohamoss,

That is almost before VB6 time of coding what is done in that sample.

In VBNet I can type it here so simple it looks for me, so not tested or
whatever

\\\
dim sr as io.streamreader
If File.exist(mypath)
Do
try
sr = new io.streamreader(mypath)
exit loop
catch
threading.thread.sleep(1000)
end try
loop
else
messagebox.show(mypath & ": does not exist")
end if
///

I hope this helps?

Cor
 
Thanks guys.

I have already seen these solutions. I need a solution that does not
involve attempting to perform an action and seeing whether an exception
occurs. Using .NET or API calls (yuck!), I need to a) ascertain whether a
file is in use and b) find out what user or process is using them.

L.
 

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

Back
Top