我有一个在本地帐户下运行但需要监视域上的文件夹的 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/