How to check if file is OPEN

  • Thread starter Thread starter Alex Simic
  • Start date Start date
A

Alex Simic

Dear All,

Is there a function in dotnet VB, which returns if a file is open or used by
other process?

Thanks, Alex
 
Alex Simic said:
Dear All,

Is there a function in dotnet VB, which returns if a file is open or used by
other process?

Open it with exclusive access and catch any exception. If an
exception occurs then it's obviously in use.
 
This has been a problem with Visual Basic since version 2.0. You'd think
Microsoft would be wise enough to add a method to the file class to check if
a file is opened and if so, ever return the username or something like that.
 
This has been a problem with Visual Basic since version 2.0. You'd think
Microsoft would be wise enough to add a method to the file class to check if
a file is opened and if so, ever return the username or something like that.

Sounds like a good idea but perhaps try to open it for write access?
Shouldn't it fail if it's open by another process? Not the most
efficient way perhaps but it should work. Of course it won't tell you
what process has it open.
 
Alex,
Is there a function in dotnet VB, which returns if a file is open or used
by
other process?
No the only possibility for that is trying to read it inside a try and catch
block.

Not much however I hope it helps something,

Cor
 
Back
Top