473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

FileSystemWatcher getting Word temp file

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?
Jul 21 '05 #1
3 6212
On Mon, 18 Oct 2004 11:20:56 -0400, zfeld wrote:
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.
Jul 21 '05 #2
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" <"dunawayc[[at]_lunchmeat_sbcglobal[dot]]net"> wrote in
message news:1m******************************@40tude.net.. .
On Mon, 18 Oct 2004 11:20:56 -0400, zfeld wrote:
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.

Jul 21 '05 #3
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

"zfeld" wrote:
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?

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jon Maz | last post by:
Hi there, I am experimenting with the FileSystemWatcher object. I have set the NotifyFilter as follows: myFileSystemWatcher.NotifyFilter = NotifyFilters.Security | NotifyFilters.CreationTime...
1
by: TD | last post by:
I'm watching a folder for new files. When the files arrive, I want to wait until it is done being written to and then move it. Every time I move a file into the test folder, it triggers 3 calls...
13
by: David | last post by:
I have been working on trying to write a directory watcher service. One of the requirments is that it be able to watch multiple directories, not sub directories of one parent directory, but just...
3
by: Stampede | last post by:
Hi, I write an application which waits for incomming files in a specified directory. I thought, that using the FileSystemWatcher would be the best, as it does exactly what I need. But now I have...
3
by: zfeld | last post by:
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...
1
by: Abel Chan | last post by:
Hi there, I was trying to write a simple NT services using .NET 2.0 and fileSystemWatcher control. The goal is to poll documents from a watch directory and ftp them to a remote web site. I...
12
by: ljh | last post by:
Has anyone else noticed that the FileSystemWatcher raises the changed event twice when a file is changed? Do you have any idea why this is the case?
2
by: piola vago | last post by:
I'm making an application that monitor a particular file (not a directoy) and when trigger a change event it start a backup process of the changed file. I'm using FileSystemWatcher component. My...
1
by: Lila Godel | last post by:
My VB.NET 2008 application is setup with a Sub Main and no forms. At run time a NotifyIcon is created with one context menu choice (Close which terminates app). I have no trouble running the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.