Click here to Skip to main content
15,891,744 members
Home / Discussions / C#
   

C#

 
GeneralRe: Boolean value changes without being modified, don't know why. Pin
aespielberg11-Jan-10 12:23
aespielberg11-Jan-10 12:23 
GeneralRe: Boolean value changes without being modified, don't know why. Pin
Luc Pattyn11-Jan-10 13:08
sitebuilderLuc Pattyn11-Jan-10 13:08 
GeneralRe: Boolean value changes without being modified, don't know why. Pin
aespielberg11-Jan-10 13:24
aespielberg11-Jan-10 13:24 
GeneralRe: Boolean value changes without being modified, don't know why. Pin
aespielberg11-Jan-10 13:34
aespielberg11-Jan-10 13:34 
GeneralRe: Boolean value changes without being modified, don't know why. Pin
Luc Pattyn11-Jan-10 13:50
sitebuilderLuc Pattyn11-Jan-10 13:50 
GeneralRe: Boolean value changes without being modified, don't know why. Pin
Daniel Grunwald12-Jan-10 6:20
Daniel Grunwald12-Jan-10 6:20 
QuestionHow do I set the "Apply onto" option in NTFS file security rights using c#? Pin
arnold_w11-Jan-10 9:12
arnold_w11-Jan-10 9:12 
AnswerRe: How do I set the "Apply onto" option in NTFS file security rights using c#? [modified] Pin
arnold_w12-Jan-10 2:52
arnold_w12-Jan-10 2:52 
I figured it out:
public struct PermissionInfo
{
  public FileSystemRights fileSystemRight;
  public AccessControlType allowOrDeny;

  public PermissionInfo(FileSystemRights fileSystemRight_, AccessControlType allowOrDeny_)
  {
    fileSystemRight = fileSystemRight_;
    allowOrDeny = allowOrDeny_;
  }
}

public enum ApplyOnto
{
  THIS_FOLDER_ONLY                     = 0,
  THIS_FOLDER_AND_SUBFOLDERS_AND_FILES = 1,
  THIS_FOLDER_AND_SUBFOLDERS           = 2,
  THIS_FOLDER_AND_FILES                = 3,
  FILES_AND_SUBFOLDERS_ONLY            = 4,
  SUBFOLDERS_ONLY                      = 5,
  FILES_ONLY                           = 6
}

private static InheritanceFlags[] inheritanceFlags = new InheritanceFlags[]
{
  InheritanceFlags.None,                                              // THIS_FOLDER_ONLY
  InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, // THIS_FOLDER_AND_SUBFOLDERS_AND_FILES
  InheritanceFlags.ContainerInherit,                                  // THIS_FOLDER_AND_SUBFOLDERS
  InheritanceFlags.ObjectInherit,                                     // THIS_FOLDER_AND_FILES
  InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, // FILES_AND_SUBFOLDERS_ONLY
  InheritanceFlags.ContainerInherit,                                  // SUBFOLDERS_ONLY
  InheritanceFlags.ObjectInherit                                      // FILES_ONLY
};

private static PropagationFlags[] propagationFlags = new PropagationFlags[]
{
  PropagationFlags.None,        // THIS_FOLDER_ONLY
  PropagationFlags.None,        // THIS_FOLDER_AND_SUBFOLDERS_AND_FILES
  PropagationFlags.None,        // THIS_FOLDER_AND_SUBFOLDERS
  PropagationFlags.None,        // THIS_FOLDER_AND_FILES
  PropagationFlags.InheritOnly, // FILES_AND_SUBFOLDERS_ONLY
  PropagationFlags.InheritOnly, // SUBFOLDERS_ONLY
  PropagationFlags.InheritOnly  // FILES_ONLY
};

public static void setDirectoryPermission(string directory, string user, PermissionInfo[] permissionInfo, ApplyOnto applyOnto)
{
  DirectoryInfo myDirectoryInfo = new DirectoryInfo(directory);
  DirectorySecurity myDirectorySecurity = myDirectoryInfo.GetAccessControl();
  for (int i = 0; i < permissionInfo.Length; i++)
  {
    myDirectorySecurity.AddAccessRule(new FileSystemAccessRule(
      user,
      permissionInfo[i].fileSystemRight,
      inheritanceFlags[(int)applyOnto],
      propagationFlags[(int)applyOnto],
      permissionInfo[i].allowOrDeny
    ));
  }

  myDirectoryInfo.SetAccessControl(myDirectorySecurity);
}


modified on Wednesday, January 13, 2010 4:11 AM

GeneralRe: How do I set the &quot;Apply onto&quot; option in NTFS file security rights using c#? Pin
batrado_®8-Feb-10 1:42
batrado_®8-Feb-10 1:42 
QuestionSend video capture over LAN Pin
shutupsquare11-Jan-10 8:58
shutupsquare11-Jan-10 8:58 
AnswerRe: Send video capture over LAN Pin
Alex Manolescu11-Jan-10 9:49
Alex Manolescu11-Jan-10 9:49 
QuestionFinding * characters in a string Pin
sleepyman11-Jan-10 8:52
sleepyman11-Jan-10 8:52 
AnswerRe: Finding * characters in a string Pin
Alex Manolescu11-Jan-10 9:31
Alex Manolescu11-Jan-10 9:31 
GeneralRe: Finding * characters in a string Pin
PIEBALDconsult11-Jan-10 14:54
mvePIEBALDconsult11-Jan-10 14:54 
AnswerRe: Finding * characters in a string Pin
Luc Pattyn11-Jan-10 9:48
sitebuilderLuc Pattyn11-Jan-10 9:48 
GeneralRe: Finding * characters in a string Pin
sleepyman12-Jan-10 8:11
sleepyman12-Jan-10 8:11 
AnswerRe: Finding * characters in a string Pin
PIEBALDconsult11-Jan-10 14:52
mvePIEBALDconsult11-Jan-10 14:52 
Questiongetting a specific tag out of a web page Dom info [modified] Pin
manustone11-Jan-10 6:39
manustone11-Jan-10 6:39 
AnswerRe: getting a specific tag out of a web page Dom info Pin
manustone12-Jan-10 20:41
manustone12-Jan-10 20:41 
QuestionMerge strings and overwrite certain characters based on a filter Pin
AndreasLa11-Jan-10 6:18
AndreasLa11-Jan-10 6:18 
AnswerRe: Merge strings and overwrite certain characters based on a filter Pin
Dave Kreskowiak11-Jan-10 6:32
mveDave Kreskowiak11-Jan-10 6:32 
AnswerRe: Merge strings and overwrite certain characters based on a filter Pin
Saksida Bojan11-Jan-10 6:38
Saksida Bojan11-Jan-10 6:38 
Questionwriting xml using datagrid Pin
naghoumeh1411-Jan-10 6:04
naghoumeh1411-Jan-10 6:04 
QuestionGetting all data from commandline app Pin
blaatschapje11-Jan-10 5:31
blaatschapje11-Jan-10 5:31 
AnswerRe: Getting all data from commandline app Pin
Alan N11-Jan-10 6:22
Alan N11-Jan-10 6:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.