VB.NET
* 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