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. directory watching

directory watching

Scheduled Pinned Locked Moved C#
csharpxmlquestion
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.
  • S Offline
    S Offline
    stephan_007
    wrote on last edited by
    #1

    Hy everyone! I know there is a c# operation, to watch a directory for changes, meaning to realize, when files are copied into it to handle them etc. this could be done by filesystemwatcher (FileSystemWatcher watcher = new FileSystemWatcher(); ) but in which order are the files which are found in this directory handled? in alphabetical order or just picking one? so lets say i copy three files to this directory b_file, a_file and c_file in which order are these files handled? and lets say there is already a d_file in it when i start the service watching, which files comes first? because i want to realize a tool which takes the files describing what to do (in xml). so the correct order is important. therefore i have to know the files are handled in the correct order. let's say a_file creates a file, b_file changes the contence and c_file copies it to it's destination. so the "commandfiles" have to be handled in correct order. that's why this info is so important for me. thanks for any hint. stephan.

    B 1 Reply Last reply
    0
    • S stephan_007

      Hy everyone! I know there is a c# operation, to watch a directory for changes, meaning to realize, when files are copied into it to handle them etc. this could be done by filesystemwatcher (FileSystemWatcher watcher = new FileSystemWatcher(); ) but in which order are the files which are found in this directory handled? in alphabetical order or just picking one? so lets say i copy three files to this directory b_file, a_file and c_file in which order are these files handled? and lets say there is already a d_file in it when i start the service watching, which files comes first? because i want to realize a tool which takes the files describing what to do (in xml). so the correct order is important. therefore i have to know the files are handled in the correct order. let's say a_file creates a file, b_file changes the contence and c_file copies it to it's destination. so the "commandfiles" have to be handled in correct order. that's why this info is so important for me. thanks for any hint. stephan.

      B Offline
      B Offline
      benjymous
      wrote on last edited by
      #2

      The files will be handled in the same order as the IO operations. Note you won't get any events for files that were already in the folder before the FileSystemWatcher is started (d_file)

      Help me! I'm turning into a grapefruit! Buzzwords!

      S 1 Reply Last reply
      0
      • B benjymous

        The files will be handled in the same order as the IO operations. Note you won't get any events for files that were already in the folder before the FileSystemWatcher is started (d_file)

        Help me! I'm turning into a grapefruit! Buzzwords!

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

        so this means, when a file enters the directory, then the trigger is started. if file a_file and b_file enter at (almost) the same time, is a_file handled first or the one which is first in? to guarantee the correct handling of the files i have to take care, a_file is there before b_file etc. is this correct? because changing contence before creating a file won't work :) or updating data which is not there because the last command should have put the data in there ;) thanks for your info. stephan.

        A 1 Reply Last reply
        0
        • S stephan_007

          so this means, when a file enters the directory, then the trigger is started. if file a_file and b_file enter at (almost) the same time, is a_file handled first or the one which is first in? to guarantee the correct handling of the files i have to take care, a_file is there before b_file etc. is this correct? because changing contence before creating a file won't work :) or updating data which is not there because the last command should have put the data in there ;) thanks for your info. stephan.

          A Offline
          A Offline
          Ashfield
          wrote on last edited by
          #4

          stephan_007 wrote:

          if file a_file and b_file enter at (almost) the same time, is a_file handled first or the one which is first in?

          It handles the first one in first. If the order is important then wait until you get a full set in before starting processing - until you have them all you can't do anything anyway, as far as I can tell from your posting.

          Bob Ashfield Consultants Ltd

          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