Detecting File State

  • Thread starter Thread starter Roger
  • Start date Start date
R

Roger

I'm looking for a way to detect if another process has a file open before
a

Make certain you know it exists, then,
Try to open the file exclusively,
an error means it is in use.
Good day,
Roger
 
Roger said:
Make certain you know it exists, then,
Try to open the file exclusively,
an error means it is in use.

I'm not proposing a better solution, but I'm pretty sure using error-
trapping or exception handling to test for a thoroughly possible condition
like this would not qualify as a "best practice"...
 
I'm looking for a way to detect if another process has a file open before a
second process tries to open it. I've looked into the FileAttr function but
I'm not sure if detecting a read-only state is sufficient. Can anyone
confirm or deny? TIA...
 
Glen,

This is endless asked, however this is as long as there are the MS-dos
operating systems and its successors not possible when you don't create a
special management tool around it, as probably in Office is done.

Cor
 
glen,

Answers on this are

do while loop condition = false
Try
Open a file
When found leave set the condition to true
Catch
threading.thread.sleep(1000)
'And set a max if you want
End

I hope this helps something

Cor
 
I have to agree. I'm thinking there must be a way to test the state of the
file for this condition. I just haven't found anything yet...
 

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