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

  • Home
  • SEARCH
  • 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 8223711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:48:30+00:00 2026-06-07T14:48:30+00:00

I have created a FileSystem watcher and have registered 2 events. One is for

  • 0

I have created a FileSystem watcher and have registered 2 events. One is for creation and other for change.

FileSystemWatcher fswInbound = new FileSystemWatcher();
fswInbound.Path = "path to directory";
fswInbound.EnableRaisingEvents = true;
fswInbound.InternalBufferSize = 12288;
fswInbound.Created += new FileSystemEventHandler(program.FileSystemWatcher_Created);
fswInbound.Changed += new FileSystemEventHandler(program.FileSystemWatcher_Created);

Than in same program I am creating files dynamically and trying to write into folder where FileSystem Watcher is listening.

using (StreamWriter outfile = new StreamWriter(filename))
{
      outfile.Write("Some really long string");
}

After a new file is created. 2 events are getting fired. One is for change and other for creation. I only want the event of file creation to trigger. How can I avoid File Change event when I am creating file for the first time?

  • 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-07T14:48:33+00:00Added an answer on June 7, 2026 at 2:48 pm

    That is by design according to MSDN To work around it I would have a common event handler which it looks like you have, Then I would check the the FileSystemEventArgs to check the ChangeType for file Creation or Change.

    From above link:

    The OnCreated event is raised as soon as a file is created. If a file is being copied or transferred into a watched directory, the OnCreated event will be raised immediately, followed by one or more OnChanged events.

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

Sidebar

Related Questions

I have a FileSystemWatcher set to check for new files, store the content in
I have a WPF application, i created a new class named Agent . On
I have created an online filesystem, based on php without using databases. It works
I have an app that uses the FileSystemWatcher to listen for Created and Deleted
I am about to implement the archetypal FileSystemWatcher solution. I have a directory to
I have created a C# Windows Service application that starts a FileSystemWatcher to monitor
I have created a QWidget with a bunch of QToolButtons in it and I
I have created 3 classes as following Ext.mine.TextParent - Inherting from Textfield Ext.mine.child.TextChildA -
I have created some JQuery that will expand a div 'popup' on hover and
I have created a JSP / servlets application running in Tomcat 7. It runs

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.