From e865f4895d83cadb5fa31faeae6729b3665343ff Mon Sep 17 00:00:00 2001 From: Devedse Date: Mon, 10 Aug 2020 00:27:30 +0200 Subject: [PATCH] Removing read only flag --- WebOptimizationProject/GitHubRepositoryOptimizer.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/WebOptimizationProject/GitHubRepositoryOptimizer.cs b/WebOptimizationProject/GitHubRepositoryOptimizer.cs index 3a3b0c7..878e2d3 100644 --- a/WebOptimizationProject/GitHubRepositoryOptimizer.cs +++ b/WebOptimizationProject/GitHubRepositoryOptimizer.cs @@ -181,7 +181,17 @@ private void CleanupRecursively(string path) { foreach (var file in Directory.GetFiles(path)) { + FileAttributes attributes = File.GetAttributes(path); + if ((attributes & FileAttributes.Hidden) == FileAttributes.ReadOnly) + { + // Show the file. + attributes = attributes & ~FileAttributes.ReadOnly; + File.SetAttributes(path, attributes); + Console.WriteLine($"Removing readonly flag for: {path}"); + } + Console.WriteLine($"Deleting file: {file}"); + File.Delete(file); }