无法从文件夹中删除ReadOnly属性

时间:2013-05-08 14:56:52

标签: vb.net attributes directory

我正在尝试删除目录的只读属性,但我不能这样做。

  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。

但是,当我右键单击我看到的目录时

enter image description here

我也在SO上看过帖子,他们应用类似于

的方法
    Dim di As New DirectoryInfo(path)
    di.Attributes =  di.attributes And Not FileAttributes.ReadOnly

但这也无济于事。

我是该机器的管理员。

0 个答案:

没有答案