How to check if the folder is empty or not?

uiautomation
studio

#1

how to check if the folder is empty or not?


#2

@kararora Follow this link


#3

Hi @kararora,

strdirPath="D:\Arivu\FolderName"

in If condition check the folder is empty or not.
If(Directory.GetFiles(strdirPath).Length == 0 && Directory.GetDirectories(strdirPath).Length == 0)

True->Folder is empty

Regards,
Arivu


#4

Directory.GetFiles(path, “*”, SearchOption.TopDirectoryOnly).Length will gives you Count of Files in the particular folder.

Directory.GetFiles(path, “*”, SearchOption.AllDirectories).Length will gives you Count of Files in the particular folder with subfolder file Count.


#5

thankyou karthick , it worked :slight_smile:


#6

thankyou arivu :slight_smile:


#7

Hello Karan


#8

Where in uipath are you gonna write this code? Thanks