标签:http io sp strong on 文件 bs ad html
文件夹锁定(Source)
private void Lock(string folderPath)
{
try
{
string adminUserName = Environment.UserName;// getting your adminUserName
DirectorySecurity ds = Directory.GetAccessControl(folderPath);
FileSystemAccessRule fsa = new FileSystemAccessRule(adminUserName, FileSystemRights.FullControl, AccessControlType.Deny);
ds.AddAccessRule(fsa);
Directory.SetAccessControl(folderPath, ds);
MessageBox.Show("Locked");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void UnLock(string folderPath)
{
try
{
string adminUserName = Environment.UserName;// getting your adminUserName
DirectorySecurity ds = Directory.GetAccessControl(folderPath);
FileSystemAccessRule fsa = new FileSystemAccessRule(adminUserName, FileSystemRights.FullControl, AccessControlType.Deny);
ds.RemoveAccessRule(fsa);
Directory.SetAccessControl(folderPath, ds);
MessageBox.Show("UnLocked");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
标签:http io sp strong on 文件 bs ad html
原文地址:http://www.cnblogs.com/dufu/p/4167682.html