Re: how to tell if a file is being accessed
- From: "Al Dunbar" <AlanDrub@xxxxxxxxxxxxxxxxxxx>
- Date: Fri, 23 May 2008 20:08:11 -0600
"parminder" <parminder@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C49CE739-CF43-48E6-9A09-29BFD1FB64D2@xxxxxxxxxxxxxxxx
Hello,
I am trying to figure out how one can tell if a file is being accessed. I
am
not worried about the kind of application accessing the file (it can be
anything from word to media player). I only want to know if a file is
being
accessed.
Any pointers will be appreciated.
First, I deduce that you have no interest in knowing who might be accessing
the file.
Which question is it that you want to be able to answer:
a) is this file being accessed right now?
b) has this file been accessed since some time in the past, say, the last
time I checked?
in scenario "a", it is possible to determine if a file is currently "open".
Forgetting scripting for a moment, this can be determined by opening up the
computer management console, and drilling down to system tools \ shared
folders \ open files.
But now it does depend on what application is being used on the file. Word,
for one example, will mark a file as open when you are editing it. In that
state, the file cannot (easily) be deleted. Another common file editor
called Notepad does not do this. Instead, it reads the file contents and
closes the file, updating it (by opening, writing, and closing) only when
specifically directed by the user. You can, in fact, have a file open for
editing in Notepad while another process deletes the file.
scenario "b" is quite different, and might be achieved by examining the
"accessed date" of the file. You could, conceivably, have a script
continually monitoring this attribute, and then notify you when it detects a
change. There might also be a way with WMI to monitor for this happening,
something along the lines of monitoring a folder for new files. Sorry,
though, but I have no experience in such aspects of WMI.
/Al
.
- Follow-Ups:
- Re: how to tell if a file is being accessed
- From: parminder
- Re: how to tell if a file is being accessed
- Prev by Date: Re: Prompt to overwrite file
- Next by Date: Re: Prompt to overwrite file
- Previous by thread: Re: Eventlog E-Mail Notification
- Next by thread: Re: how to tell if a file is being accessed
- Index(es):
Relevant Pages
|
Loading