C# Delete Bin And Obj Folder
https://www.codeproject.com/Tips/429485/Delete-specific-folders-using-recursion
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
DeleteBinAndObj(@"D:\SJ-Audiance\Backend");
}
private static void DeleteBinAndObj(string rootPath)
{
DirectoryInfo rootFolder = new DirectoryInfo(rootPath);
DirectoryInfo[] subfolders = rootFolder.GetDirectories();
foreach (DirectoryInfo myItem in subfolders)
DeleteBinAndObj(myItem.FullName);
//delete the specific folder
if (rootFolder.Name.Equals("bin") || rootFolder.Name.Equals("Bin") || rootFolder.Name.Equals("BIN") ||
rootFolder.Name.Equals("obj") || rootFolder.Name.Equals("Obj") || rootFolder.Name.Equals("OBJ"))
{
try
{
Directory.Delete(rootFolder.FullName, true);
/// here you can log the deleted file FullName.
}
catch
{
/// Access denied for few of the files inside the directory.
return;
}
}
}
}
}