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;
}
我得到一个错误说 - “目录名称是无效的” ...
我不知道是什么原因造成这个错误,因为网络路径是可访问的,当我使用的凭据访问它手动。