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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:58:17+00:00 2026-06-08T01:58:17+00:00

Possible Duplicate: Detecting moved files using FileSystemWatcher I was looking for a solution to

  • 0

Possible Duplicate:
Detecting moved files using FileSystemWatcher

I was looking for a solution to watch a directory and notify my app whenever a new file is moved into the directory. The Obvious solution was to use FileSystemWatcher class of the .NET.

But the problem is , it raises a event a new file is created/deleted in the folder but does not raises event when a file is moved/copied into the folder.

Can anyone tell me what could be the cause of such behavior.

my code is

static void Main(string[] args)
    {
        Run();
    }

    [PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
    public static void Run()
    {
        // Create a new FileSystemWatcher and set its properties.
        FileSystemWatcher watcher = new FileSystemWatcher();
        watcher.Path = @"D:\New folder";
        /* Watch for changes in LastAccess and LastWrite times, and
           the renaming of files or directories. */
        watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
           | NotifyFilters.FileName | NotifyFilters.DirectoryName;
        // Only watch text files.
        watcher.Filter = "*.txt";

        // Add event handlers.
        watcher.Changed += new FileSystemEventHandler(OnChanged);
        watcher.Created += new FileSystemEventHandler(OnChanged);
        watcher.Deleted += new FileSystemEventHandler(OnChanged);
        watcher.Renamed += new RenamedEventHandler(OnRenamed);

        // Begin watching.
        watcher.EnableRaisingEvents = true;

        // Wait for the user to quit the program.
        Console.WriteLine("Press \'q\' to quit the sample.");
        while (Console.Read() != 'q') ;
    }

    // Define the event handlers.
    private static void OnChanged(object source, FileSystemEventArgs e)
    {
        // Specify what is done when a file is changed, created, or deleted.
        Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
    }

    private static void OnRenamed(object source, RenamedEventArgs e)
    {
        // Specify what is done when a file is renamed.
        Console.WriteLine("File: {0} renamed to {1}", e.OldFullPath, e.FullPath);
    }
  • 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-08T01:58:20+00:00Added an answer on June 8, 2026 at 1:58 am

    I used FileSystemWatcher in one of my Home application. But FileSystemWatcher do not have any move or copy detection events as per my knowledge.

    As per MSDN

    Copying and moving folders

    The operating system and FileSystemWatcher object interpret a
    cut-and-paste action or a move action as a rename action for a folder
    and its contents. If you cut and paste a folder with files into a
    folder being watched, the FileSystemWatcher object reports only the
    folder as new, but not its contents because they are essentially only
    renamed.

    For more information click here.

    What I did was monitoring the parent folder and sub folders and logged every changes in it.
    To include sub directories I used the following property.

    watcher.IncludeSubdirectories=true;
    

    Some googling suggesting to use timer to detect changes. But I don’t know how effective it is.

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

Sidebar

Related Questions

Possible Duplicate: Detecting moved files using FileSystemWatcher I'm trying to monitor moved files with
Possible Duplicate: Detecting SMS incoming and outgoing I want to write a app that
Possible Duplicate: Detecting an “invalid date” Date instance in JavaScript I was using the
Possible Duplicate: Detecting IE using jQuery Hello, I'm trying to figure out how to
Possible Duplicate: Detecting presence of a scroll bar in a DIV using jQuery? There
Possible Duplicate: How can my android app detect a dropped call? Detecting outgoing call
Possible Duplicate: iOS - Detecting whether or not device support phone calls? I'm writing
Possible Duplicate: PHP detecting request type (GET, POST, PUT or DELETE) This should be
Possible Duplicate: Detect multitouch with Ontouch listener Android I have a question about detecting
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP

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.