C# – How to set permissions for a directory (Windows only)

When you want to set permissions for a directory (and its files/subdirectories), you can use DirectoryInfo.GetAccessControl() to get the directory’s security, add/modify/remove access control rules, and then use DirectoryInfo.SetAccessControl() to apply the changes. Access control rules are a complex combination of different settings. They control being able to do things like creating a file in … Read more

C# – How to create directories

You can use Directory.CreateDirectory() to create a directory at the specified path (absolute or relative), like this: This creates the directory if it doesn’t exist, otherwise it does nothing. That means you don’t need to check if the directory exists before calling Directory.CreateDirectory(). In this article, I’ll go into more details about using Directory.CreateDirectory(). CreateDirectory() … Read more