Count no of files in inside folders


the above screen has 4 folder and Outer folder BP41693 i need to read to get the File count inside all the 4 folders . there are N no of PDF files in the above 4 folders.
below logic is not working . How to get count of files inside 4 folders.

Directory.GetFiles(“Data\Downloading_files\BP41693”).Count

Hi @shashank_dullu

Try this

Directory.GetFiles("Data\Downloading_files\BP41693","*", SearchOption.AllDirectories).Count

The * is a wildcard tha you can use for filter file by extension, name etc


*.pdf
*.xlsx
*.txt 
*.csv
invoice*.pdf
*2023.xlsx

* alone = all files
2 Likes

@shashank_dullu

directory.GetFiles("C:\Users\cogni\Downloads\userforum","*.pdf",SearchOption.AllDirectories).Count

if they are pdf files use this
for any type of files you will get the count which is given by @rikulsilva

1 Like

For Pdf Count inside all the folders

directory.GetFiles(“Data\Downloading_files\BP41693”,“*.pdf”,SearchOption.AllDirectories).Count

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