Search code examples
c#filesystemwatcher

FileSystemWatcher on a network machine setting credential


Is there a way to set a credential for a filesystemwatcher object?

The application runs on a different user that doesnt have access to directory on network machine but i want to give credentials to filesystemwatcher object so it can listen that directory.

Is it doable?


Solution

  • No. Just make sure that your application runs under an account that has the correct privileges to access the resources you want to access.

    You might want to check out the following StackOverflow answer which shows how you can impersonate another user account when using the FileSystemWatcher:

    FileSystemWatcher running under impersonated user