how to check if the folder is empty or not?
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
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
thankyou arivu
Hello Karan
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)
Regards,
Avanish
hello Karaora can you upload the file.
Use this code
thanks for sample code
Hi Naresh,
Hope so, code will resolve your issue.
If you need any further assistance let me know.
Regards,
Avanish
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
Directory.GetFiles(folderPath).Length = 0 and Directory.GetDirectories(folderPath).Length = 0
Have you tried this? use only 1 equal sign.
hi
itβs not working at my end.
can u please try
for your refrence i am attached folder
Test.zip (987 Bytes)
please any one help