Vb.net Windows服务(文件副本)使用管理员帐户运行,但访问路径被拒绝
我用vb.net开发了一个windows服务,它监视一个特定的文件夹,当发生文件重命名事件时,将文件复制到另一个文件夹。该服务是在Microsoft Windows 2012[版本6.3.9600]上安装的。 下面是核心代码Vb.net Windows服务(文件副本)使用管理员帐户运行,但访问路径被拒绝,vb.net,exception,windows-services,unauthorized,Vb.net,Exception,Windows Services,Unauthorized,我用vb.net开发了一个windows服务,它监视一个特定的文件夹,当发生文件重命名事件时,将文件复制到另一个文件夹。该服务是在Microsoft Windows 2012[版本6.3.9600]上安装的。 下面是核心代码 Private Sub DoWhenFileRenamed(ByVal Source As Object, ByVal evnt As RenamedEventArgs) . . . FileName = evnt.FullPath.Subs
Private Sub DoWhenFileRenamed(ByVal Source As Object, ByVal evnt As RenamedEventArgs)
.
.
.
FileName = evnt.FullPath.Substring(Len(x) + 1)
TmpPath = "c:\tmp\"+random name+"\"
Directory.CreateDirectory(TmpPath)
File.Copy(evnt.FullPath, TmpPath + FileName, True)
.
.
.
该服务以管理员权限运行,但当我将文件重命名为System.UnauthorizedAccessException时,会出现以下消息:
Access to the path <evnt.FullPath> is denied
对路径的访问被拒绝
谢谢你的帮助