Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
DirectoryInfo myDirectoryInfo = new DirectoryInfo(textBox1.Text);
DirectorySecurity myDirectorySecurity = myDirectoryInfo.GetAccessControl();
string User = System.Environment.UserDomainName + @"\" +
                                           comboBox1.SelectedItem.ToString();
myDirectorySecurity.ResetAccessRule(new FileSystemAccessRule(User,
                              FileSystemRights.Read   , AccessControlType.Deny ));
myDirectoryInfo.SetAccessControl(myDirectorySecurity);
MessageBox.Show("Permissions Altered Successfully");


I have written this program to lock a folder.. and it is doing so.. but when i try to unlock any of the folder locked by this except the folder from c: drive .. it gives a message. unauthoruzed access exception... why i m getting this message.. how to fix this??? thanks in advance for ur solution

[edit]Code block added, "Treat my content as plain text..." option disabled. "\\" changed to @"\" to prevent confusing syntax colorizer. - OriginalGriff[/edit]
Posted
Updated 22-Jan-12 21:12pm
v2
Comments
Lakamraju Raghuram 23-Jan-12 1:26am    
Can you give the code you have done for unlocking.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900