FilersystemWatcher在模拟用户下运行(FileSystemWatcher running under impersonated user)

编程入门 行业动态 更新时间:2024-10-23 05:45:13
FilersystemWatcher在模拟用户下运行(FileSystemWatcher running under impersonated user)

我有一个c#winform应用程序在本地帐户下运行,但需要监视域中的文件夹。 我使用从这里稍微修改的代码复制文件,并且工作正常。 可以使用类似的代码与FileSystemWatcher设置模拟,以便我可以监视域上的文件夹?

I have an c# winform application that runs under a local account but needs to monitor folders on a domain. I am using slightly modified code from here to copy the files and that works fine. Can similar code be used with the FileSystemWatcher set up impersonation so I can monitor a folder on a domain?

最满意答案

是的,这里有一个很好的模拟类,将这个类包含在你的项目中,而不是简单地将FileSystemWatcher放置在如下的使用块中:

using ( new Impersonator( "myUsername", "myDomainname", "myPassword" ) ) { ... <code that executes under the new context> ... }

Yes, there is a good impersonation class here, include this class in your project and than simply place your FileSystemWatcher within a using block like this:

using ( new Impersonator( "myUsername", "myDomainname", "myPassword" ) ) { ... <code that executes under the new context> ... }

更多推荐

本文发布于:2023-08-05 00:47:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1424587.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:用户   FileSystemWatcher   FilersystemWatcher   user   impersonated

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!