Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. FileSystemWatcher doesnt seem to be working on Win7

FileSystemWatcher doesnt seem to be working on Win7

Scheduled Pinned Locked Moved C#
helpdatabase
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gareth H
    wrote on last edited by
    #1

    This is the first time i've used a FileSystemWatcher, so i might well be doing something very basic wrong. The code below is what i use to start the FileSystemWatcher.

    _fileSystemWatcher = new FileSystemWatcher(path, "*.sql");
    _fileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite;
    _fileSystemWatcher.Created += new FileSystemEventHandler(FileSystemWatcher_Created);
    _fileSystemWatcher.Error += new ErrorEventHandler(FileSystemWatcher_Error);

    _fileSystemWatcher.EnableRaisingEvents = true;

    But, i never seem to get an events raised. The path is set to the correct folder and i am creating files with an sql extension when my program runs, so i thought i would see some info. I am running Win7, if thats any help...

    Regards, Gareth. (FKA gareth111)

    L J 2 Replies Last reply
    0
    • G Gareth H

      This is the first time i've used a FileSystemWatcher, so i might well be doing something very basic wrong. The code below is what i use to start the FileSystemWatcher.

      _fileSystemWatcher = new FileSystemWatcher(path, "*.sql");
      _fileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite;
      _fileSystemWatcher.Created += new FileSystemEventHandler(FileSystemWatcher_Created);
      _fileSystemWatcher.Error += new ErrorEventHandler(FileSystemWatcher_Error);

      _fileSystemWatcher.EnableRaisingEvents = true;

      But, i never seem to get an events raised. The path is set to the correct folder and i am creating files with an sql extension when my program runs, so i thought i would see some info. I am running Win7, if thats any help...

      Regards, Gareth. (FKA gareth111)

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I just try your code, it works if you remove the line with "NotifyFilter".

      G 1 Reply Last reply
      0
      • L Lost User

        I just try your code, it works if you remove the line with "NotifyFilter".

        G Offline
        G Offline
        Gareth H
        wrote on last edited by
        #3

        Cheers. I changed it to "NotifyFilters.FileName", as i am only interested in new files being created.

        Regards, Gareth. (FKA gareth111)

        1 Reply Last reply
        0
        • G Gareth H

          This is the first time i've used a FileSystemWatcher, so i might well be doing something very basic wrong. The code below is what i use to start the FileSystemWatcher.

          _fileSystemWatcher = new FileSystemWatcher(path, "*.sql");
          _fileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite;
          _fileSystemWatcher.Created += new FileSystemEventHandler(FileSystemWatcher_Created);
          _fileSystemWatcher.Error += new ErrorEventHandler(FileSystemWatcher_Error);

          _fileSystemWatcher.EnableRaisingEvents = true;

          But, i never seem to get an events raised. The path is set to the correct folder and i am creating files with an sql extension when my program runs, so i thought i would see some info. I am running Win7, if thats any help...

          Regards, Gareth. (FKA gareth111)

          J Offline
          J Offline
          Jacobb Michael
          wrote on last edited by
          #4

          Hi, but filewatcher costs process overload. why cant you try with API Hooking you can track all the newly opened files and even you can block creating/edit/delete file activities. unless i know the situation for what you are using filewatcher i cant suggest even hooking.

          G 1 Reply Last reply
          0
          • J Jacobb Michael

            Hi, but filewatcher costs process overload. why cant you try with API Hooking you can track all the newly opened files and even you can block creating/edit/delete file activities. unless i know the situation for what you are using filewatcher i cant suggest even hooking.

            G Offline
            G Offline
            Gareth H
            wrote on last edited by
            #5

            The app is going to be very small. All it does is watch a folder, if new files are created, alert the user and then the user runs something in the program. At the moment it is using 11k of memory, so i dont think this is an issue. Its also an internal app, so i know what systems it will be run on, and they are fast.

            Regards, Gareth. (FKA gareth111)

            J 1 Reply Last reply
            0
            • G Gareth H

              The app is going to be very small. All it does is watch a folder, if new files are created, alert the user and then the user runs something in the program. At the moment it is using 11k of memory, so i dont think this is an issue. Its also an internal app, so i know what systems it will be run on, and they are fast.

              Regards, Gareth. (FKA gareth111)

              J Offline
              J Offline
              Jacobb Michael
              wrote on last edited by
              #6

              hi, Ya fine ! you are correct, i have given the situation where the file watcher is done for the entire system(all the logical and removable drives) as you mentioned for watching one folder, it wont cost performance issues. do proceed...!

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups