我正在尝试删除目录的只读属性,但我不能这样做。
Private _attributes As FileAttributes = FileAttributes.Normal
Private Sub RemoveReadOnlyDirectoryAttributes(ByVal path As String)
'Check root folder
Dim di As New DirectoryInfo(path)
di.Attributes = _attributes
'Check sub folders
For Each folder As String In Directory.GetDirectories(path, "*", SearchOption.AllDirectories)
di = New DirectoryInfo(folder)
di.Attributes = _attributes
Next
End Sub
我原以为这段代码会将属性更新为Normal。
但是,当我右键单击我看到的目录时
我也在SO上看过帖子,他们应用类似于
的方法 Dim di As New DirectoryInfo(path)
di.Attributes = di.attributes And Not FileAttributes.ReadOnly
但这也无济于事。
我是该机器的管理员。