Click here to Skip to main content
15,905,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am developing a window application in c#.net. I want to make my folder lock. Folder can't be delete, open, copy and paste. Only I want to insert the images in folder by pragmatically and retrieve those images.

This is my code. Using this, I am only able to insert the images and also can't delete the folder but when I am going to move this folder in some other folder that can be move and after moving the folder all rights are removed.

How to do this ? Please help me out.

private void Permissionbtn_Click_1(object sender, EventArgs e)
{
           DirectoryInfo myDirectoryInfo = new DirectoryInfo(textBox1.Text);          
           DirectorySecurity myDirectorySecurity = myDirectoryInfo.GetAccessControl();
           string User = System.Environment.UserDomainName + "\\" +                                                     comboBox1.SelectedItem.ToString();
           myDirectorySecurity.AddAccessRule(new FileSystemAccessRule(User,                                     FileSystemRights.ListDirectory, AccessControlType.Deny));
}
Posted

1 solution

 
Share this answer
 
v2
Comments
Brinda Lakhani 17-Feb-15 23:58pm    
I tried. Its not working.
[no name] 18-Feb-15 0:07am    
just nw i am upadted few links above.please chk and try again Brinda.

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