Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3235452
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:30:29+00:00 2026-05-17T17:30:29+00:00

Whenever I am subscribing to FileSystemWatcher notification, multiple events are occuring when I create

  • 0

Whenever I am subscribing to FileSystemWatcher notification, multiple events are occuring when I create new file or change existing file. Events are occuring in following sequence:

New File

Created

Changed

Changed

Changed

Changed

Changed

Changed

Change

Changed

Deleted

Changed

Rename

Renamed

Delete

Deleted

Rename and Delete are working as expected. Created and Changed are invoked multiple time.

Is there any solution/workaround for getting exact notification when files are added/changed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:30:30+00:00Added an answer on May 17, 2026 at 5:30 pm

    If you look at the SDF source code for the FSW, you’ll see it’s actually a pretty thin managed shim around the native SHChangeNotifyRegister call with the dwEventMask set to SHCNE_ALLEVENTS. A window handle is passed to the API that then receives callbacks when changes occur and those callbacks are marshalled to the managed events the FSW exposes on the managed side.

    Now looking at the callback, it looks like there are 9 event IDs that are handles, four of which raise a Changed event:

    • SHCNE_UPDATEDIR
    • SHCNE_RMDIR
    • SHCNE_UPDATEITEM
    • SHCNE_ATTRIBUTES

    So when you create a new file, it’s SHCNE_CREATE gives you the Created event, followed by some other callbacks raising several Changed events. Are all of the event args the same on the change events? If they are, you’d have to use the debugger to step through the SDF code to see exactly what is coming in and for which actual callbacks.

    The short story here is that the SDF is simply forwarding the events that the OS is giving to it. The reason you see all of these events is because the OS sending them. Exactly why it is sending them may be the way the OS is handling the file, or it may even be specific to the file system driver you’re using (i.e. on another device it might be slightly different, or even on another disk in the same device).

    The workaround I think would be to look at the event args and “group” the events for the same file name that happen in quick succession. For example if you get a bunch of Changed and a Created event for the same file name in the same folder all within a second, then it’s a good bet that it was a file creation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whenever I try to edit existing or create new distribution provisioning profile on iOS
Whenever I create a new Empty MVC3 Web Application project in Visual Studio 2010
Whenever I create a Temporary file in C++ Native WinAPI, the HANDLE returned is
I have a service responsible for subscribing to EWS for new mail notification. I've
Whenever i tried to use Table.create :a=>a, :b=>b or tab=Table.new tab.a=a tab.b=b tab.save! produces
Whenever I created a new VB.NET program I must go into the project's properties
Whenever a model is created in my application, an email is sent out to
I've been playing around with subscribing elements to AJAX events in jQuery. I have
This is a follow-on question to Is publishing/subscribing to events after UI rendering a
Whenever we start a new iteration I have to set the default value for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.