/// <summary> /// Directory의 잠금을 해제합니다. /// </summary> /// <param name="folderPath"></param> private static void UnLock(string folderPath) { try { string adminUserName = Environment.UserName;// getting your adminUserName System.Security.AccessControl.DirectorySecurity ds = System.IO.Directory.GetAccessControl(folderPath); System.Security.AccessControl.FileSystemAccessRule fsa = new System.Security.AccessControl.FileSystemAccessRule(adminUserName, System.Security.AccessControl.FileSystemRights.FullControl, System.Security.AccessControl.AccessControlType.Deny); ds.RemoveAccessRule(fsa); System.IO.Directory.SetAccessControl(folderPath, ds); } catch (Exception ex) { } } /// <summary> /// Directory를 잠급니다. /// </summary> /// <param name="folderPath"></param> private static void Lock(string folderPath) { try { string adminUserName = Environment.UserName;// getting your adminUserName System.Security.AccessControl.DirectorySecurity ds = System.IO.Directory.GetAccessControl(folderPath); System.Security.AccessControl.FileSystemAccessRule fsa = new System.Security.AccessControl.FileSystemAccessRule(adminUserName, System.Security.AccessControl.FileSystemRights.FullControl, System.Security.AccessControl.AccessControlType.Deny); ds.AddAccessRule(fsa); System.IO.Directory.SetAccessControl(folderPath, ds); } catch (Exception ex) { } }
'.Net > Winform' 카테고리의 다른 글
C# 자신의 IP 및 MAC ADRESS 확인하기 (0) | 2012.08.29 |
---|---|
C# Ping 확인 (0) | 2012.08.28 |
C# ListView Headr Column Size 변경 막기 (0) | 2012.08.28 |
C# Excel 작성 (0) | 2012.08.28 |
C# 리소스 언어 설정 (0) | 2012.08.22 |