윈도우 보안기능을 활용한 폴더 잠그기및 풀기
*
Imports System.Security.AccessControl
Imports System.IO

Public Class Form1

Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click

With FolderBrowserDialog1

If .ShowDialog() = DialogResult.OK Then
txtbxBrowseFolderName.Text = .SelectedPath
End If

End With

End Sub

Private Sub btnLock_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLock.Click

Dim fs As FileSystemSecurity = File.GetAccessControl(txtbxBrowseFolderName.Text)

fs.AddAccessRule(New FileSystemAccessRule(Environment.UserName, FileSystemRights.FullControl, AccessControlType.Deny))

File.SetAccessControl(txtbxBrowseFolderName.Text, fs)

End Sub

Private Sub btnUnlock_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUnlock.Click

Dim fs As FileSystemSecurity = File.GetAccessControl(txtbxBrowseFolderName.Text)

fs.RemoveAccessRule(New FileSystemAccessRule(Environment.UserName, FileSystemRights.FullControl, AccessControlType.Deny))

File.SetAccessControl(txtbxBrowseFolderName.Text, fs)

End Sub

End Class
  • 윈도우의 보안 기능을 이용한 방법이다
1.png

이 게시물을

댓글'1'

이 댓글을

공유하기

SEARCH

MENU NAVIGATION