Check folder is empty or not

I have attached the folder structure. I have to check if the folder is empty or not.

if the folder is empty, I have to read the email or else notify the business team.

Plz assist me

Cheers!
MicrosoftTeams-image

Hi @Iswarya_P1

You can try with Path Exists activity to find a folder/File exists or not.

Output will be return as boolean value.

Regards
Gokul

Hi @Iswarya_P1

Use Folder Exists activity and store the output in a variable.
It’s an Boolean value.

Use an If condition and pass the variable.
In then block do the necessary workflow and in else block do the necessary workflow.

Hope you understand!!

I have check folder is empty or not of each run

@Iswarya_P1

You need to check if folder has files or not…if so try this

Directory.GetFiles("FodlerPath").Count>0 use in if…

this will give true if files exists in folder else false

cheers

Hi @Iswarya_P1
=> Write the conditions in Assign activity:

folderPath= "C:\Path\To\Your\Folder"
filePaths= Directory.GetFiles(folderPath)
subfolderPaths= Directory.GetDirectories(folderPath)

Note:folderPath is of Datatype string. filePaths, subfolderPaths is of Datatype Array of String.

=> Drag and drop a “Flow Decision” activity below the previous “Assign” activities.
=> In the condition of the “Flow Decision,” enter the following expression:

(filePaths.Length + subfolderPaths.Length) = 0

=> Add two branches to the “Flow Decision” activity: one for when the folder is empty and one for when it’s not.
Flow Decision Branches
→ Inside the branch for when the folder is empty, you can use a “Log Message” activity to output a message saying the folder is empty.
→ Inside the other branch (when the folder is not empty), you can use a “Log Message” activity to output a message saying the folder is not empty.

Hope it helps!!

Hi @Iswarya_P1

Directory.GetFiles(“FolderPath”).Count

This gives the count

Use it in if condition
Directory.GetFiles(“FolderPath ”).Count=0
Then read email or else inform business team

Hi @Iswarya_P1

=> Take a assign activity and create a array of string varibale, let call the varibale name as Arr_Files

- Assign -> Arr_Files = Directory.getfiles("folder path")
In Arr_Files varibale stores the files in the specified folder.

=> Take a If condition after assign activity.

condition - **Arr_Files.Any**

=> In then block insert an send outlook mail message activity to send a mail to the business team.
=> In else block insert the mail activities to read the mails.

The above condition checks the folder has any files. If files is there it went to then block, if there is no files it went to else block.

If you have any queries let us know and we will clear your doughts.

Hope it helps!!