我有一个情况,我有一个 Windows 应用程序,如果它不存在,它将在服务器上创建文件夹,然后我会将文件复制到它,但目前我在指定路径上被拒绝访问。这就是我所拥有的。
If (Not System.IO.Directory.Exists(sdPath & "\DONE")) Then
System.IO.Directory.CreateDirectory(sdPath & "\DONE")
sdFileInfo.MoveTo(sdPath & "\DONE\" & sdFileName & sdFileInfo.Extension)
Else
sdFileInfo.MoveTo(sdPath & "\DONE\" & sdFileName & sdFileInfo.Extension)
End If
如何授予完全访问权限?
我有这段测试代码,看看我是否可以获得权限,但似乎不起作用。
txtPath.Text = "\\ServerName\images\dbpics\POLPICS\55\Polpics\Actual\"
Dim sFolderPath As String = txtPath.Text
Dim sUserAccount As String = "(DomainName\Administrator)"
Dim oFolderInfo As IO.DirectoryInfo = New IO.DirectoryInfo(sFolderPath)
Dim oFolderAcl As New DirectorySecurity(txtPath.Text, System.Security.AccessControl.AccessControlSections.Access)
oFolderAcl.AddAccessRule(New FileSystemAccessRule(sUserAccount, _
FileSystemRights.FullControl, _
AccessControlType.Allow))
oFolderInfo.SetAccessControl(oFolderAcl)
oFolderAcl = Nothing
oFolderInfo = Nothing
enter code here