FileSystemWatcher runs as a licensed user

I have a winform C # application that runs under a local account, but you need to control the folders in the domain. I am using slightly modified code here to copy files and this works fine. Can similar code be used with a FileSystemWatcher created by impersonation so that I can control a folder in a domain?

+3
source share
2 answers

Yes, there is a good impersonation class here , include this class in your project and just place your FileSystemWatcher in a usage block like this

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

   <code that executes under the new context>

   ...
}
+6

:

, , (.. ).

, winform.

FileSystemWatcher Windows domian .

, .

+1

Source: https://habr.com/ru/post/1739501/