how to check if the folder is empty or not?
@kararora Follow this link
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
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.
thankyou karthick , it worked
Where in uipath are you gonna write this code? Thanks
@cyruspogii based on your requirement you can use this code, if you simply want a count and save it. You can right this code in assign activity.
If you want to do further operation based on the result then use in if condition as per the above questions requirement.
Take 1 If activity, in the condition part write down
Directory.GetFiles(strdirPath).Length == 0 && Directory.GetDirectories(strdirPath).Length == 0
as per requirement write data in true and false part. For your reference I am attaching a sample code.Test1.xaml (6.2 KB)
hello Karaora can you upload the file.
Use this code
thanks for sample code
Hope so, code will resolve your issue.
If you need any further assistance let me know.
concat string sapmle code could u share?
Wont work for me I have a variable with the Folderpath as string.
want to check if the folder its empty or not. It will contain only pdf files