private static void EnsureDirectoriesPermission(params string[] directories) { var missingPermissions = new List <string>(); foreach (var directory in directories) { if (IOExtensions.EnsureReadWritePermissionForDirectory(directory) == false) { missingPermissions.Add(directory); } } if (missingPermissions.Count > 0) { throw new UnauthorizedAccessException( $"Couldn't gain read/write access to the following directories:{Environment.NewLine}{string.Join(Environment.NewLine, missingPermissions)}"); } }