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开发者_如何学C network machine but i want to give credentials to filesystemwatcher object so it can listen that directory.
Is it doable?
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
If you can use the credentials to create a WindowsIdentity object, you can call Impersonate on it before setting up the FileSystemWatcher object.
精彩评论