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. Multiple instances of FileSystemWatcher

Multiple instances of FileSystemWatcher

Scheduled Pinned Locked Moved C#
csharp
5 Posts 4 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.
  • J Offline
    J Offline
    JadsHari
    wrote on last edited by
    #1

    I have been working on trying to write a directory watcher service. One of the requirments is that it be able to watch multiple directories, not sub directories of one parent directory, but just multiple directories. Using FileSystemWatcher in .Net Thanks in Advance Hari

    S S A 3 Replies Last reply
    0
    • J JadsHari

      I have been working on trying to write a directory watcher service. One of the requirments is that it be able to watch multiple directories, not sub directories of one parent directory, but just multiple directories. Using FileSystemWatcher in .Net Thanks in Advance Hari

      S Offline
      S Offline
      Seishin
      wrote on last edited by
      #2

      well, I don't see the problem.. just use some a number of FileSystemWatcher objects..

      life is study!!!

      1 Reply Last reply
      0
      • J JadsHari

        I have been working on trying to write a directory watcher service. One of the requirments is that it be able to watch multiple directories, not sub directories of one parent directory, but just multiple directories. Using FileSystemWatcher in .Net Thanks in Advance Hari

        S Offline
        S Offline
        SatyaDY
        wrote on last edited by
        #3

        Hi You can do it creating Multiple FileSystemWatcher Objects. Here is a code snippet of it. //Folder to be monitered are placed in Appconfig seperated with ; char[] delimiterChars = { ';' }; string FoldersNames = ConfigurationSettings.AppSettings["FoldersToMonitor"]; string[] fileNames = FoldersNames.Split(delimiterChars, System.StringSplitOptions.None); foreach (string s in fileNames) { FileSystemWatcher Clientwatcher = new FileSystemWatcher(); Clientwatcher.Path = s; Clientwatcher.Filter = "*"; Clientwatcher.NotifyFilter = NotifyFilters.LastAccess; // Clientwatcher.Created += new FileSystemEventHandler(OnChanged); Clientwatcher.Changed += new FileSystemEventHandler(OnChanged); // Clientwatcher.Renamed += new RenamedEventHandler(OnRenamed); Clientwatcher.EnableRaisingEvents = true; fw.Add(Clientwatcher); } Enjoy. Satya

        S 1 Reply Last reply
        0
        • S SatyaDY

          Hi You can do it creating Multiple FileSystemWatcher Objects. Here is a code snippet of it. //Folder to be monitered are placed in Appconfig seperated with ; char[] delimiterChars = { ';' }; string FoldersNames = ConfigurationSettings.AppSettings["FoldersToMonitor"]; string[] fileNames = FoldersNames.Split(delimiterChars, System.StringSplitOptions.None); foreach (string s in fileNames) { FileSystemWatcher Clientwatcher = new FileSystemWatcher(); Clientwatcher.Path = s; Clientwatcher.Filter = "*"; Clientwatcher.NotifyFilter = NotifyFilters.LastAccess; // Clientwatcher.Created += new FileSystemEventHandler(OnChanged); Clientwatcher.Changed += new FileSystemEventHandler(OnChanged); // Clientwatcher.Renamed += new RenamedEventHandler(OnRenamed); Clientwatcher.EnableRaisingEvents = true; fw.Add(Clientwatcher); } Enjoy. Satya

          S Offline
          S Offline
          SatyaDY
          wrote on last edited by
          #4

          Sorry forgot the declaration of fw. It's an arraylist. ArrayList fw = new ArrayList(); Satya

          1 Reply Last reply
          0
          • J JadsHari

            I have been working on trying to write a directory watcher service. One of the requirments is that it be able to watch multiple directories, not sub directories of one parent directory, but just multiple directories. Using FileSystemWatcher in .Net Thanks in Advance Hari

            A Offline
            A Offline
            amitrajput284
            wrote on last edited by
            #5

            Please see the following link. i think it will help you. http://www.codeproject.com/useritems/AdvancedFileSystemWatcher.asp

            asd

            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