How do I copy security information when creating a new folder?
Posted
by dhh
on Stack Overflow
See other posts from Stack Overflow
or by dhh
Published on 2010-04-27T15:06:19Z
Indexed on
2010/04/27
15:13 UTC
Read the original article
Hit count: 266
In my app I'm creating folders for archiving old stuff from a harddisc.
When creating a new folder I must copy all NTFS rights (Groups / Users) from the source folder to the newly created destination folder.
Here is what I've written so far:
FileSecurity fileSecurity =
File.GetAccessControl(filenameSource, AccessControlSections.All);
FileAttributes fileAttributes = File.GetAttributes(filenameSource);
File.SetAccessControl(filenameDest, fileSecurity);
File.SetAttributes(filenameDest, fileAttributes);
Is this really all I ought to do or am I missing something important?
© Stack Overflow or respective owner