Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2008
    Thanked 0 Times in 0 Posts

    System.IO.FileSystemWatcher - permissions required for watching

    Hi - looking for help answering a question that's bugging me. I have developed a Windows service that watches directories using the System.IO.FileSystemWatcher object. The directory to watch is set via the config file for the service. The Windows service runs under an account that's a member of the Administrators group on the machine it's installed to.

    The problem is getting the FileSystemWatcher to watch a directory that's on another machine in the same domain. When the directory to watch is on another machine, the Windows service throws an invalid directory Exception. This is because the service doesn't have the required permissions on the other machine.

    I thought there might be 2 ways to solve this.
    1. Make the account the Windows service runs under a member of the Administrators group on the other machine. OR
    2. Give the account the Windows service runs full control over the directory on the other machine.

    The first solution works (making the account an Administrator). The second, which is my preferred solution because it involves a more limited set of permissions, doesn't. I can't understand why not. Why wouldn't you be able to have a FileSystemWatcher watch a directory on another machine that you have full control over?

    Can anyone shed some light on this?

  2. #2
    Regular Coder
    Join Date
    Oct 2006
    United Kingdom
    Thanked 30 Times in 29 Posts
    Make sure that the account that the service runs under is capable of reading, writing and accessing that directory. In other words, check the effective permissions

    1- Right mouse click on the folder...and select Security & sharing
    2- Select the security tab and click on the advanced button
    3- Select the Effective Permissions tab
    4- Click on Select and enter the user name

    You will be able to see all the effective permissions for that user.

    You will need to ensure that the directory in question does not inherit from its parent directory....and that permissions for that user applies to all sub-directories.

    It might be a good idea to login under that user...and see if it is possible to navigate the directory, alter its contents...etc.



Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts