I want to delete the empty folder which is in folder of folder of folder.can u give any solution for that.?
Can’t you just use the Delete activity. Works for files or folders
Hi @Navyareddy,
dirPath="D:\Arivazhagan\New Folder"
in If condition check the folder is empty or not.
If(Directory.GetFiles(dirPath).Length == 0 && Directory.GetDirectories(dirPath).Length == 0)
If return true Use Delete activity to delete the folder.
Regards,
Arivu
Thank You, But before that i want to get all folders in folders and sub folders also.Actually I have a new file directory ,in that 4 folders ,again each folder having 5 folders ,those are empty so i want to display all those first and then delete those 5 folders…can u help me?
Hi @Navyareddy,
private static void processDirectory(string startLocation)
{
foreach (var directory in Directory.GetDirectories(startLocation))
{
processDirectory(directory);
if (Directory.GetFiles(directory).Length == 0 &&
Directory.GetDirectories(directory).Length == 0)
{
Directory.Delete(directory, false);
}
}
}
Use code like this to delete all empty folder inside sub folders also.
Regards,
Arivu
it shows expression error in if condition.
What error you are getting
Thanks a lot it worked for me… thank you so much for the fast replay.