Hi All,
Have a requirement to get the count of total files from a folder where that main folder has few subfolders inside it
Thanks
Hi All,
Have a requirement to get the count of total files from a folder where that main folder has few subfolders inside it
Thanks
Hi @Harshita_D
Can you check this expression
System.IO.Directory.GetFiles(“yourFolderPath”,“.”,searchOption.AllDirectories).Length
This will give you the total count
Hi @Harshita_D
=> Drag and drop a “Assign” activity onto your workflow.
fileCount= Directory.GetFiles("C:\Your\Main\Folder", "*", SearchOption.AllDirectories).Length
=> Drag and drop a “Log Message” activity (or any other activity you want to perform with the file count) to display the fileCount variable.
Hope it helps!!
Hi @Harshita_D
To get the count of total files from a folder that contains subfolders, you can use the following steps in UiPath:
Use the “Directory.GetFiles” Method:
Directory.GetFiles method in UiPath to get a list of all files in the main folder and its subfolders.filesArray = Directory.GetFiles("C:\YourMainFolder\", "*", SearchOption.AllDirectories)
Replace "C:\YourMainFolder\" with the path to your main folder.
Get the Count of Files:
filesArray.Length property to get the total count of files.Here’s a simplified UiPath workflow to achieve this:
Sequence:
- Assign (filesArray = Directory.GetFiles("C:\YourMainFolder\", "*", SearchOption.AllDirectories))
- Assign (fileCount = filesArray.Length)
- Log Message ("Total Files Count: " + fileCount.ToString)
Make sure to replace "C:\YourMainFolder\" with the actual path to your main folder. After running this workflow, the total count of files in the main folder and its subfolders will be displayed in the output log.
Thanks!!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.