Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- class DeleteBinAndObjFolders
- {
- public static void BinObjFoldersDestroyer(string directoryName)
- {
- DirectoryInfo directory = new DirectoryInfo(directoryName);
- foreach (DirectoryInfo subdirectory in directory.GetDirectories())
- {
- BinObjFoldersDestroyer(subdirectory.FullName);
- if (subdirectory.Name == "bin" || subdirectory.Name == "obj")
- {
- Console.WriteLine(subdirectory.FullName);
- subdirectory.Delete(true);
- }
- }
- }
- public static void StartMenu()
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.Write("Folder: ");
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.WriteLine("{0}", Directory.GetCurrentDirectory());
- Console.WriteLine();
- Console.Write("Do you really want to delete all ");
- Console.ForegroundColor = ConsoleColor.Red;
- Console.Write("bin");
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.Write(" and ");
- Console.ForegroundColor = ConsoleColor.Red;
- Console.Write("obj");
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.WriteLine(" folders inside this folder!!!");
- }
- static void Main(string[] args)
- {
- StartMenu();
- Console.ReadLine();
- BinObjFoldersDestroyer(Directory.GetCurrentDirectory());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement