我正在尝试使用 Windows 服务在某些服务器路径上运行文件观察程序。我正在使用我的 Windows 登录凭据来运行该服务,并且能够从我的登录中访问这个“someServerPath”。但是当我从 FileSystemWatcher 执行此操作时,它会抛出:
目录名称 \someServerPath 无效”异常。
var fileWatcher = new FileSystemWatcher(GetServerPath())
{
NotifyFilter=(NotifyFilters.LastWrite|NotifyFilters.FileName),
EnableRaisingEvents=true,
IncludeSubdirectories=true
};
public static string GetServerPath()
{
return string.Format(@"\\{0}", FileServer1);
}
谁能帮我解决这个问题?