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. Watching for a file

Watching for a file

Scheduled Pinned Locked Moved C#
csharpdotnetquestion
4 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.
  • A Offline
    A Offline
    Andy M
    wrote on last edited by
    #1

    I'm sure there is a class to do what I want in the .NET Framework but I cannot remember what it is called right now. I am writing a service that will sit and wait for a new file to appear in a specific directory. It will then process the file and move it to an archive directory. I just need a pointer to the class/method that will allow me to watch the directory. My other solution is to read the contents of the directory every few seconds and process the files, but I am sure there is already a pre-existing solution that will do that for me. Can any one point me in the right direction? Or is this a fictional class that I drempt up somewhere?

    G S 2 Replies Last reply
    0
    • A Andy M

      I'm sure there is a class to do what I want in the .NET Framework but I cannot remember what it is called right now. I am writing a service that will sit and wait for a new file to appear in a specific directory. It will then process the file and move it to an archive directory. I just need a pointer to the class/method that will allow me to watch the directory. My other solution is to read the contents of the directory every few seconds and process the files, but I am sure there is already a pre-existing solution that will do that for me. Can any one point me in the right direction? Or is this a fictional class that I drempt up somewhere?

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      System.IO.FileSystemWatcher :) --- b { font-weight: normal; }

      A 1 Reply Last reply
      0
      • G Guffa

        System.IO.FileSystemWatcher :) --- b { font-weight: normal; }

        A Offline
        A Offline
        Andy M
        wrote on last edited by
        #3

        That's fantastic. Thanks. It was exactly what I was looking for! :-D

        1 Reply Last reply
        0
        • A Andy M

          I'm sure there is a class to do what I want in the .NET Framework but I cannot remember what it is called right now. I am writing a service that will sit and wait for a new file to appear in a specific directory. It will then process the file and move it to an archive directory. I just need a pointer to the class/method that will allow me to watch the directory. My other solution is to read the contents of the directory every few seconds and process the files, but I am sure there is already a pre-existing solution that will do that for me. Can any one point me in the right direction? Or is this a fictional class that I drempt up somewhere?

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

          It is the FileSystemWatcher class. It responds to different events such as create, change, renamed etc.

          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