Get number of files in a folder (and it's subfolders etc.)

hey everyone,

so i want to get the number of files that are in a specific folder (and all it’s subfolders).

i get that by using this.

image

is there also another way to get this answer without using “get folder info” activity?

kind regards!

Yes we can use expressions like this

Using assign activity

arr_filepath = Directory.GetFiles(”your main folderpath” ,”*.*”, SearchOption.AllDirectories)

Where arr_filepath is a variable of type type array of strings

Cheers @muehlbauer157

1 Like

Hi,

You can use this
in assign activity

Int_Count = System.IO.Directory.GetFiles(“yourFolderPath”,“.”,searchOption.AllDirectories).Length

1 Like

Hi @muehlbauer157

Can you try with this expression

Directory.GetFiles(Environment.CurrentDirectory+"\Input\","*.*",SearchOption.AllDirectories)

SearchOption.AllDirectories - Used for searching all the directories in the mentioned folder path

Regards
Gokul

1 Like

Hi @muehlbauer157

- Assign (folderPath = "C:\YourFolderPath")
- Assign (fileCount = 0)

- Invoke Code
  - Code:
    ```
    Directory.GetFiles(folderPath, "*", SearchOption.AllDirectories).Count
    ```
  - Result: fileCount

- Now, the fileCount variable contains the count of files in the specified folder and subfolders.

Hope it helps

i get this error

this works thanks! :slight_smile:

Can u click on activity and share the error that shows as a pop up
@muehlbauer157

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