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

Locked files

P: n/a
How can you tell if a file is locked/being written to by another process?

-Cam
Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Joe
Hi Cameron,

What I did was verify that the file exists and than attempt to open the file
in ReadWrite mode. If this fails, I than try to open in Read mode. If it
still fails, than the file is open and locked for exclusive access.

-Joe

"Cameron" <ca*****@appdepot.com> wrote in message
news:11*************@corp.supernews.com...
How can you tell if a file is locked/being written to by another process?

-Cam

Nov 17 '05 #2

P: n/a
Doesn't that seem excessively heavy? If you look at something like
handle.exe, it can give you a complete list of all of the locked files
on your system, (really quickly), but some how I can't see it attempting
to open every file in write mode.

There has to be a API somewhere that can give this type of information.

-Cam

Joe wrote:
Hi Cameron,

What I did was verify that the file exists and than attempt to open the file
in ReadWrite mode. If this fails, I than try to open in Read mode. If it
still fails, than the file is open and locked for exclusive access.

-Joe

"Cameron" <ca*****@appdepot.com> wrote in message
news:11*************@corp.supernews.com...
How can you tell if a file is locked/being written to by another process?

-Cam


Nov 17 '05 #3

P: n/a
No it's not that heavy, beside, Handle.exe doesn't give you the information
you really need, it only says that a (file)handle is associated with a
certain file, but it doesn't say how the file is opened and how it can be
shared.
It's not because a file is opened by process A that it cannot be used by
process B, all depends on the open mode and the share mode, no-one stops you
from opening a file in read mode multiple times, note that it's even
possible to open a file for shared write access, how would handle.exe be of
any help here?

Willy.

"Cameron" <ca*****@appdepot.com> wrote in message
news:11*************@corp.supernews.com...
Doesn't that seem excessively heavy? If you look at something like
handle.exe, it can give you a complete list of all of the locked files on
your system, (really quickly), but some how I can't see it attempting to
open every file in write mode.

There has to be a API somewhere that can give this type of information.

-Cam

Joe wrote:
Hi Cameron,

What I did was verify that the file exists and than attempt to open the
file in ReadWrite mode. If this fails, I than try to open in Read mode.
If it still fails, than the file is open and locked for exclusive access.

-Joe

"Cameron" <ca*****@appdepot.com> wrote in message
news:11*************@corp.supernews.com...
How can you tell if a file is locked/being written to by another process?

-Cam



Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.