c# - 在模拟用户下运行的 FileSystemWatcher

标签 c# impersonation filesystemwatcher

我有一个在本地帐户下运行但需要监视域上的文件夹的 c# winform 应用程序。我正在使用来自 here 的略微修改的代码复制文件,效果很好。是否可以将类似的代码与 FileSystemWatcher 设置模拟一起使用,以便我可以监视域中的文件夹?

最佳答案

是的,有一个很好的模拟类here ,将此类包含在您的项目中,而不是像这样简单地将您的 FileSystemWatcher 放在 using block 中:

using ( new Impersonator( "myUsername", "myDomainname", "myPassword" ) )
{
   ...

   <code that executes under the new context>

   ...
}

关于c# - 在模拟用户下运行的 FileSystemWatcher,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2562542/

相关文章:

c# - 几代垃圾收集器是什么意思?

sql - WCF 模拟和 SQL 可信连接?

c# - 如何获取 Windows 服务登录用户的安全 token ?

c# - FileSystemWatcher 停止捕捉事件

c# - c#如何判断一个文件夹是否复制完成

c# - 获取 owin cookie 名称

c# - 流利的 : Table name different from entity name

c# - 如何设置MongoDB自动为每个子文档分配ID?

c# - core 2.0 - 模拟 Windows 用户的最佳方式?

c# - Filesystemwatcher 和 GAC