-
Mar 17th, 2010, 11:54 AM
#1
Thread Starter
Hyperactive Member
filesystemwatcher filters
I am using about 5 different filesystemwatcher routines total.
I am using the following code:
Code:
filewatch.NotifyFilter = NotifyFilters.CreationTime Or NotifyFilters.LastWrite
AddHandler filewatch.Created, AddressOf addfile
AddHandler filewatch.Changed, AddressOf addfile
filewatch.EnableRaisingEvents = True
However, there is one problem with it... whenever I open a file and change stuff, then close it without saving the changes, the events still fire. I am opening excel workbooks in code, then use xlsWB.Close(SaveChanges:=False) to close them, and the event still fires, where the file isn't really changed so it should not fire.
-
Mar 17th, 2010, 02:08 PM
#2
Addicted Member
Re: filesystemwatcher filters
When I tried this I noticed that each time I opened an Excel file the date modified changed in my directory to the current date/time and then when I closed the file it changed back to the files original date/time. So, from looking at the file it appeared not to have changed the date modified property of the file, but, actually changed it twice.
Try opening a directory in Windows Explorer where an old Excel file is. Open the file and see if the time stamp changes. Then close the file without making any changes and see if it then changes back. Both of these events would cause your code to enter the addfile handler.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|