By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,698 Members | 1,265 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,698 IT Pros & Developers. It's quick & easy.

Detecting File State

P: n/a
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...
Nov 21 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
> 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
Nov 21 '05 #2

P: n/a
"Roger" <ro***@pcsrevenuecontrol.com> wrote:
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.


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"...

--
Michael Kellogg
Nov 21 '05 #3

P: n/a
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
Nov 21 '05 #4

P: n/a
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...

"Michael Kellogg" <mk******@WEDELIVERcc3.com> wrote in message
news:Xn**********************************@207.46.2 48.16...
"Roger" <ro***@pcsrevenuecontrol.com> wrote:
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.


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"...

--
Michael Kellogg

Nov 21 '05 #5

P: n/a
It's 'The eternal question', then...

"Cor Ligthert" <no************@planet.nl> wrote in message
news:uO**************@TK2MSFTNGP15.phx.gbl...
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

Nov 21 '05 #6

P: n/a
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
Nov 21 '05 #7

P: n/a
Interesting....I'll try that. Thanks.

"Cor Ligthert" <no************@planet.nl> wrote in message
news:uf**************@tk2msftngp13.phx.gbl...
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

Nov 21 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.