在vb.net中移动或重命名时如何阻止文件夹或文件

时间:2019-01-12 11:09:14

标签: vb.net

  1.   

    如果移动或重命名文件夹或文件错误消息生成,我需要文件或文件夹...

  2.   

    如果文件夹移动或复制,则记录在文本文件中,例如日志...生成

             If txtSearchitem.Text <> "" Then
                Dim filepath As String = txtSearchitem.Text
                Dim dir As DirectoryInfo = New DirectoryInfo(filepath)
                Dim user = New SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, Nothing)
                Dim Security As DirectorySecurity = dir.GetAccessControl()
                Security.AddAccessRule(New FileSystemAccessRule(user, FileSystemRights.FullControl, AccessControlType.Allow))
                Security.AddAccessRule(New FileSystemAccessRule(user, FileSystemRights.ReadAndExecute, AccessControlType.Allow))    
                dir.SetAccessControl(Security)
                MsgBox("Folder is unlocked", vbInformation, "Unlock")
                txtSearchitem.Text = ""
            Else
                MsgBox("Please browse the folder to lock.", vbInformation, "lock")
            End If
    

0 个答案:

没有答案