locked
FileSystemWatcher vs Symbolic Links RRS feed

  • Question

  • hallo,

    if I attach FileSystemWatcher object with IncludeSubdirectories set to true to a directory including subdirectories which are symlinks, file system changes made in target-directories do not generate events watched by the FSW object on the top directory.
    (If I attach FSW directly onto a symlink-directory, everything works right)

    Please, is there any setting or workaround to achieve desired effect? Is it possible to monitor file system changes in directory structure which contents symlinks?

    thank you
    Tuesday, June 16, 2009 5:21 AM

Answers

  • Hi,

    Do you mean you have attached a filesystemwatcher to a symlink?
    As far as I can see,  FileSystemWatcher is used to watch a directory and can not watch symlink or a directory through symlink.

    So I would suggest you resolve the absolute path of these directories and set FileSystemWatcher to each directory.

    Harry
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Harry Zhu Tuesday, June 23, 2009 8:43 AM
    Friday, June 19, 2009 7:36 AM

All replies

  • Hi,

    I don't think these symlink files are subdirectory.
    You might need to resolve the absolute path of these directories and set FileSystemWatcher to each directory.

    Harry
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, June 17, 2009 7:59 AM
  • thanks for answering,
    I know the symlinked directories are actually files, but their purpose is to act as directories, so I thought FSW coud be ready to resolve even these scenarios.

    Problem is I cannot change the behavior of a service which watches only one dir and all the structure under it.
    My service can only delete files in subdirectories.
    Now I have resolved all the situation without symlinks, but I would like to know if there is a way to propagate the events even through symlinks.

    If I understand it well, when i attach the FSW to symlink-dir, system attaches it physically to a target-dir, but when the FSW is attached to a dir which's subdirs are symlinks, system would have to have some list of all symlinks and would have to replicate the events generated on target-dir to all it's symlinks, which could be to difficult or ineffecient.

    The ideas of symlinks and filesystemwatcher perhaps are hardly joinable.
    Wednesday, June 17, 2009 12:45 PM
  • Hi,

    Do you mean you have attached a filesystemwatcher to a symlink?
    As far as I can see,  FileSystemWatcher is used to watch a directory and can not watch symlink or a directory through symlink.

    So I would suggest you resolve the absolute path of these directories and set FileSystemWatcher to each directory.

    Harry
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Harry Zhu Tuesday, June 23, 2009 8:43 AM
    Friday, June 19, 2009 7:36 AM