Check if any excel file exists in a path (all in subfolders)

Hello, I have a main folder and 20+ subfolders stored inside of this main folder. There can be multiple excel workbooks or zero workbook stored in each of these subfolders (but none directly inside of the main folder). I need to check if there is any excel workbook saved in any of these subfolders, if not (no workbook saved in any of these subfolders) I’ll terminate workflow otherwise a process will run. How can I check that? Thank you so much in advance.

@lynnsong986

Try below expression in IF activity.

       Directory.GetFiles("MainFolderPath","*.xlsx",SearchOptions.AllDirectories).Count > 0

The above expression will give true if atleast one excel file exists in Main or its sub-folders else not.

@lakshman many thanks for your quick response!!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.