Created
March 17, 2021 06:21
-
-
Save shawnwildermuth/182f3236860522e52d7b5b4625b781d7 to your computer and use it in GitHub Desktop.
Top-Level Example for Cleaning Visual Studio projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Linq; | |
using static System.Console; | |
WriteLine("VSCleaner..."); | |
if (args.Length != 1) | |
{ | |
WriteLine("You must supply a directory name."); | |
WriteLine("VSCleaner {DirectoryName}"); | |
return; | |
} | |
var toBeDeleted = new string[] { "bin", "obj", "node_modules" }; | |
if (new DirectoryInfo(args[0]).Exists) | |
{ | |
CleanDirectories(args[0]); | |
} | |
WriteLine("Completed..."); | |
void CleanDirectories(string dirName) | |
{ | |
var directories = Directory.GetDirectories(dirName); | |
foreach (var directory in directories) | |
{ | |
var info = new DirectoryInfo(directory); | |
if (toBeDeleted.Contains(info.Name.ToLower())) | |
{ | |
WriteLine($"Deleting {directory}"); | |
info.Delete(true); | |
} | |
else | |
{ | |
CleanDirectories(directory); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment