Results 1 to 2 of 2

Thread: filesystemwatcher filters

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2008
    Location
    PA
    Posts
    365

    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.

  2. #2
    Addicted Member
    Join Date
    Mar 2010
    Location
    Southeast Michigan
    Posts
    155

    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.
    Dave

    Helpful information I've found here so far : The Definitive "Passing Data Between Forms" : Restrict TextBox to only certain characters, numeric or symbolic :
    .NET Regex Syntax (scripting) : .NET Regex Language Element : .NET Regex Class : Regular-Expressions.info
    Stuff I've learned here so far : Bing and Google are your friend. Trying to help others solve their problems is a great learning experience

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width