Making ".\bin", ".\Release", ".\Debug", ".\obj" not read-only, after accidentally setting the root folder of you’re Microsoft Visual Studio solution to "read-only".

You can use this script:

 

 

string sourceFolder = @"C:\Projects"; foreach (string folder in Directory.GetDirectories(sourceFolder, "*", SearchOption.AllDirectories)) { if (folder.EndsWith(@"\obj") || folder.EndsWith(@"\bin") || folder.EndsWith(@"\Release") || folder.EndsWith(@"\Debug"))     {       DirectoryInfo test = new DirectoryInfo(folder);       test.Attributes = FileAttributes.Normal;

       foreach(DirectoryInfo dir in test.GetDirectories("*", SearchOption.AllDirectories))         {

          dir.Attributes = FileAttributes.Normal;

         }

foreach (string file in Directory.GetFiles(folder, "*", SearchOption.AllDirectories))         { File.SetAttributes(file, FileAttributes.Normal); File.Delete(file);          }

} }

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.