How to remove "Read only" property for a Folder using .net(Windows application using c#)
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Former memberPosted Feb 8, 2012, 8:41 PM EST
DirectorySecurity myDirectorySecurity = myDirectoryInfo.GetAccessControl();
FileSystemAccessRule fc = (new FileSystemAccessRule("EveryOne",FileSystemRights.FullControl, AccessControlType.Deny));
// here you wrote ur Group/Username like Authenticated User or SYSTEM insted of everyone
myDirectoryInfo.SetAccessControl(myDirectorySecurity);
myDirectorySecurity.RemoveAccessRule(fc);
myDirectorySecurity.AddAccessRule(new FileSystemAccessRule(User,FileSystemRights.FullControl, AccessControlType.Allow));
myDirectoryInfo.SetAccessControl(myDirectorySecurity);
MessageBox.Show("Changed Permissions Successfully");