brinda lakhani

brinda lakhani

  • NA
  • 13
  • 5.8k

How to lock folder by programmatically in c#.net?

Feb 20 2015 2:03 AM
I am developing a window application of screen capturing for my company use. I want capture the screen shoot and store those screen shots automatically in lock folder by programming. And after storing, i want to upload those screen shots on my company's server from that lock folder. so, I don't want to perform operations like delete, copy, paste on that folder. My problem is that, when I write Fullcontrol then I'm not able to store that screen shots in folder. So, Please tell me, how to do this? Which kind of access i have to give?

This is my code: 
 
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.Read , AccessControlType.Deny));

myDirectoryInfo.SetAccessControl(myDirectorySecurity);

MessageBox.Show("Permissions Altered Successfully");
}

Answers (1)