I am working on an application that requires that some files are copied to a different folder. I use the following:
DirectoryInfo dir = new DirectoryInfo(path);
foreach (FileInfo filesindires in dir.GetFiles())
{
FileSecurity ds = filesindires.GetAccessControl();
ds.AddAccessRule(new FileSystemAccessRule("Authenticated Users",
FileSystemRights.FullControl, AccessControlType.Deny));
filesindires.SetAccessControl(ds);
}
With that method I deny the user from opening the file, but I would like to only prevent copying. How can I prevent that a file is copied while allowing the user to read it?