FileSystemWatcher getting Word temp file

Z

zfeld

My app is creating a word document which my app calls saveas() and saves it
to a given directory that is being watched by a fileSystemWatcher. The
problem is that the fileSystemEventHandler for creation is only called for
the temporary filed created by word which shows up as ~$documentName.doc the
real file named MyDocument.doc will never invoke the fileSystemEventHandler
for creation. Now when the user closes Word the temporary file is deleted
and my app only had a handle to that file.
How come I am not getting any notification about the creation of the real
file even though it was saved using saveas() and I do see it created in
windows explorer?
 
C

Chris Dunaway

My app is creating a word document which my app calls saveas() and saves it
to a given directory that is being watched by a fileSystemWatcher. The
problem is that the fileSystemEventHandler for creation is only called for
the temporary filed created by word which shows up as ~$documentName.doc the
real file named MyDocument.doc will never invoke the fileSystemEventHandler
for creation. Now when the user closes Word the temporary file is deleted
and my app only had a handle to that file.
How come I am not getting any notification about the creation of the real
file even though it was saved using saveas() and I do see it created in
windows explorer?

Off the top of my head, I would say that the temp file is being created and
then renamed to the final filename. When a file is renamed, a create is
not fired for the new name. Try setting up your FileSystemWatcher to
handle the rename event.

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 
Z

zfeld

Thanks,

What I discovered is that the temporary ~$documentName.doc never gets
renamed, it is just deleted on close. However another file is created at the
same time as the ~$documentName.doc that doesn't even have the .doc
extension, which was why I wasn't seeing it, it is usually something like
wrd005.tmp this then gets subsequently renamed into MyDocument.doc. I
therefore had to ignore the creates of .doc files that start with ~ and
catch renames from a .tmp extension to .doc extensions.


Chris Dunaway said:
My app is creating a word document which my app calls saveas() and saves
it
to a given directory that is being watched by a fileSystemWatcher. The
problem is that the fileSystemEventHandler for creation is only called
for
the temporary filed created by word which shows up as ~$documentName.doc
the
real file named MyDocument.doc will never invoke the
fileSystemEventHandler
for creation. Now when the user closes Word the temporary file is deleted
and my app only had a handle to that file.
How come I am not getting any notification about the creation of the real
file even though it was saved using saveas() and I do see it created in
windows explorer?

Off the top of my head, I would say that the temp file is being created
and
then renamed to the final filename. When a file is renamed, a create is
not fired for the new name. Try setting up your FileSystemWatcher to
handle the rename event.

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 
G

Guest

in the onchanged event handler use the following code
if file.getextension(e.fullpath).substring(0,1)<>"~" then
write ur code here
end if

regards
soni
 

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

Top