FileSystemWatcher on a network machine setting credential

谁说胖子不能爱 提交于 2019-12-11 00:26:05

问题


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?


回答1:


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




回答2:


If you can use the credentials to create a WindowsIdentity object, you can call Impersonate on it before setting up the FileSystemWatcher object.



来源:https://stackoverflow.com/questions/7118961/filesystemwatcher-on-a-network-machine-setting-credential

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!