1
我有一個Windows服務,旨在監視文件路徑,並稍後對創建的文件執行一些操作。目錄名稱<Path>無效|冒充| Windows服務
要監視的位置是我模擬的用戶具有完全訪問權限的網絡位置。
LOGON32_LOGON_INTERACTIVE = 3;
LOGON32_PROVIDER_DEFAULT = 0;
string watchPath = @"\\servername\Folder\";
using (new Impersonator("UserName", "Domain", "Password"))
{
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
FSWatcher = new FileSystemWatcher();
FSWatcher.Path = watchPath; \\ POINT OF ERROR
FSWatcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName;
FSWatcher.Filter = "*.xls";
FSWatcher.Created += new FileSystemEventHandler(OnChanged);
FSWatcher.EnableRaisingEvents = true;
FSWatcher.IncludeSubdirectories = false;
}
我得到一個錯誤說 - 「目錄名稱是無效的」 ...
我不知道是什麼原因造成這個錯誤,因爲網絡路徑是可訪問的,當我使用的憑據訪問它手動。