public void SetDirectoryPermission() { try { if (!HasFolderPermission) { return; } Assert.IsFalse(IoDir.DirectoryExists(TestFolder + "//"), "Invalid directory path"); Assert.IsTrue(IoDir.CreateDirectory(TestFolder + "//"), "Error creating directory"); Assert.IsTrue(IoDir.DirectoryExists(TestFolder + "//"), "Error creating directory"); var permissions = IoDir.GetDirectoryPermission(TestFolder + "//"); Assert.IsTrue(permissions.Any(), "Error getting directory permissions"); FileSystemRights?newPermission = null; foreach (var permission in (FileSystemRights[])System.Enum.GetValues(typeof(FileSystemRights))) { if (permissions.All(p => p != permission)) { newPermission = permission; break; } } Assert.IsNotNull(newPermission, "Error getting permission"); Console.WriteLine("Permission to set: {0}", newPermission); var permissionProccessResult = IoDir.SetDirectoryPermission(TestFolder + "//", (FileSystemRights)newPermission); if (!permissionProccessResult) { Assert.Inconclusive("Error setting directory permission"); } permissions = IoDir.GetDirectoryPermission(TestFolder + "//"); Assert.IsNotNull(permissions.FirstOrDefault(p => p == newPermission), "Error setting permission"); } finally { if (HasFolderPermission) { IoDir.DeleteDirectory(TestFolder + "//"); } } }