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 8762271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:29:08+00:00 2026-06-13T15:29:08+00:00

I have a FileSystemWatcher that checks multiple directories if there are any files created.

  • 0

I have a FileSystemWatcher that checks multiple directories if there are any files created.

            ((System.ComponentModel.ISupportInitialize)(FileMonitor)).BeginInit();
            FileMonitor.EnableRaisingEvents = true;
            FileMonitor.Created += new FileSystemEventHandler(FileMonitor_Created);
            FileMonitor.Path = Path.ToString();
            FileMonitor.IncludeSubdirectories = true;
            FileMonitor.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.Attributes;
            ((System.ComponentModel.ISupportInitialize)(FileMonitor)).EndInit();

For some reason the FileMonitor_Created event is not always fired when running the application, even though it should. It feels random…

However, if I put a breakpoint at the FileMonitor_Created method, it works perfectly: The event fires everytime it should, if the breakpoint is set.

I’ve tried setting an InterBufferSize for the FileMonitor, but that had no effect.

Update

I added the Changed event to the Filemonitor and gave it the same handler as for the Created event. Somehow it works now, although the file is actually created, not changed.

I’m still curious why it always worked ‘the old way’ when setting a breakpoint.

  • 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-06-13T15:29:09+00:00Added an answer on June 13, 2026 at 3:29 pm

    How many changes are you making?

    The Windows operating system notifies your component of file changes
    in a buffer created by the FileSystemWatcher. If there are many
    changes in a short time, the buffer can overflow. This causes the
    component to lose track of changes in the directory, and it will only
    provide blanket notification. Increasing the size of the buffer with
    the InternalBufferSize property is expensive, as it comes from
    non-paged memory that cannot be swapped out to disk, so keep the
    buffer as small yet large enough to not miss any file change events.
    To avoid a buffer overflow, use the NotifyFilter and
    IncludeSubdirectories properties so you can filter out unwanted change
    notifications.

    Taken from MSDN

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

Sidebar

Related Questions

I have a FileSystemWatcher that processes files based on file system events. After awhile,
I have a FileSystemWatcher monitoring a directory that receives TIF files from a scanning
I have an app that uses the FileSystemWatcher to listen for Created and Deleted
We have several .NET applications that monitor a directory for new files, using FileSystemWatcher.
I have created a C# Windows Service application that starts a FileSystemWatcher to monitor
I have a project that uses the .net FileSystemWatcher to watch a Samba network
We have an asp.net mvc application that we would like to integrate a FileSystemWatcher
I have a FileSystemWatcher set to check for new files, store the content in
We have built a window service that listens to folders with FileSystemWatcher , when
I have a issue with my FileSystemWatcher. I have application that needs to monitor

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.