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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:55:49+00:00 2026-06-12T18:55:49+00:00

How do you check for a newly created file. This only works for an

  • 0

How do you check for a newly created file. This only works for an edited file.

        DateTime time = DateTime.Now;             // Use current time
        string format = "dMyyyy";            // Use this format
        string s = time.ToString(format); 



        fileSystemWatcher1.Path = @"C:\Users\Desktop\test\";
        fileSystemWatcher1.NotifyFilter =   NotifyFilters.LastAccess | 
                                            NotifyFilters.LastWrite | 
                                            NotifyFilters.FileName | 
                                            NotifyFilters.DirectoryName;

        fileSystemWatcher1.IncludeSubdirectories = false;
        fileSystemWatcher1.Filter = s + ".txt";
  • 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-12T18:55:50+00:00Added an answer on June 12, 2026 at 6:55 pm

    Following the example outlined in this article C#: Application to Watch a File or Directory using FileSystem Watcher

    You need to describe what has to be done when one of these attributes in fileSystemWatcher1.NotifyFilter gets altered by assigning different event handlers to different activities. For example:

    fileSystemWatcher1.Changed += new FileSystemEventHandler(OnChanged);
    fileSystemWatcher1.Created += new FileSystemEventHandler(OnChanged);
    fileSystemWatcher1.Deleted += new FileSystemEventHandler(OnChanged);
    fileSystemWatcher1.Renamed += new RenamedEventHandler(OnRenamed);
    

    With the signatures of both the handlers as

    void OnChanged(object sender, FileSystemEventArgs e)
    void OnRenamed(object sender, RenamedEventArgs e)
    

    Example handler for OnChanged

    public static void OnChanged(object source, FileSystemEventArgs e)
    {
       Console.WriteLine("{0} : {1} {2}", s, e.FullPath, e.ChangeType);
    }
    

    And then enable the watcher to raise events:

    fileSystemWatcher1EnableRaisingEvents = true;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Check this link! I am having the hardest time trying to figure out why
I need to check if the data of a newly created OverlayItem is already
I'm successfully importing external contacts into the newly created account using this tutorial .
I need to do some background post-processing on newly created objects in Django. This
Check this code : HTML : <div style="position: absolute; visibility: visible; width: 172px;"> <img
Check this page. On either firefox, chrome, or IE9 / 10 the tabs on
check this out: template <class T> class Test: public T { public: void TestFunc()
check this example: > a = matrix(1:9, nrow = 3, ncol = 3, dimnames
Check this code (My Custom Keyboard): -(IBAction) updateTextBackSpace:(id)sender { if([txtview.text length]>0) { NSString *deletedLastCharString
Check out this jsbin . I have a form with a custom button that

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.