FileSystemWatcher Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Al Reid

    #1

    FileSystemWatcher Question

    I have been asked to write a program to monitor a certain directory
    structure and to copy all files created there to optical media for archival
    storage. It seems that it would be simple to monitor the directory for
    file creation and just copy the files. I am concerned that while doing the
    copy a "Created" event may get lost and the file not get archived. How
    would I handle this?

    Would it be feasible to put the paths of the newly created files into a FIFO
    queue and to have a separate thread monitor the FIFO and do the copying?
    Would that work? If so, how would I go about creating and running the
    separate thread. I've never dealt with threads before. Also, would it be
    better to have more that one thread, or is that asking for trouble?

    TIA,

    --
    Al Reid


  • Al Reid

    #2
    Re: FileSystemWatch er Question

    I thought I would have gotten some input, thoughts or suggestions.

    "Al Reid" <areidjr@reidDA SHhome.com> wrote in message news:%23b50%23T HxFHA.1148@TK2M SFTNGP11.phx.gb l...[color=blue]
    > I have been asked to write a program to monitor a certain directory
    > structure and to copy all files created there to optical media for archival
    > storage. It seems that it would be simple to monitor the directory for
    > file creation and just copy the files. I am concerned that while doing the
    > copy a "Created" event may get lost and the file not get archived. How
    > would I handle this?
    >
    > Would it be feasible to put the paths of the newly created files into a FIFO
    > queue and to have a separate thread monitor the FIFO and do the copying?
    > Would that work? If so, how would I go about creating and running the
    > separate thread. I've never dealt with threads before. Also, would it be
    > better to have more that one thread, or is that asking for trouble?
    >
    > TIA,
    >
    > --
    > Al Reid
    >
    >[/color]


    Comment

    • Al Reid

      #3
      Re: FileSystemWatch er Question

      Well, in the absence of any input telling me not to do it, I went ahead an coded up a prototype. It monitors a directory structure
      for creation and change events and places the events into a shared queue. A worker thread monitors the queue and performs the copy
      operations into a "mirror" location. It seems to be working well and I don't seem to be loosing any events, even when monitoring a
      network share.

      The only puzzling thing is that I get multiple events for the same file at times. It looks like I get 1, 2 or 3 events in sequence.
      Perhaps I'm getting separate change events for file size, last write time, etc. Does anyone have any suggestions as to how to
      handle this. Worst case, it just copies/overwrites the file multiple times to the same location.

      Thanks for your input and insight.

      --
      Al Reid

      "Al Reid" <areidjr@reidDA SHhome.com> wrote in message news:%23b50%23T HxFHA.1148@TK2M SFTNGP11.phx.gb l...[color=blue]
      > I have been asked to write a program to monitor a certain directory
      > structure and to copy all files created there to optical media for archival
      > storage. It seems that it would be simple to monitor the directory for
      > file creation and just copy the files. I am concerned that while doing the
      > copy a "Created" event may get lost and the file not get archived. How
      > would I handle this?
      >
      > Would it be feasible to put the paths of the newly created files into a FIFO
      > queue and to have a separate thread monitor the FIFO and do the copying?
      > Would that work? If so, how would I go about creating and running the
      > separate thread. I've never dealt with threads before. Also, would it be
      > better to have more that one thread, or is that asking for trouble?
      >
      > TIA,
      >
      > --
      > Al Reid
      >
      >[/color]


      Comment

      Working...