I need to get file details of PDF files saved in a directory and its sub folders.
Eg: C:\Primary —> Inside this directory I need to get all PDF files eventhough it is found inside the subfolder
I tried using Directory.GetFiles(“C:\Primary”,“*.pdf”), this is not picking files from the sub folder.
Please suggest some idea
@Deeipauk try getting all subfolders in the directory first using Directory.GetDirectories(“Folder Path”).
check this post.
Assign strArray(system.string)= Directory.GetDirectories(“Folder Path”)
Use For each loop to itirate through all the folder.
Once you have all subfolders in an array.
Use a for each item in subfolders array and use Directory.GetFiles(“C:\Primary"+item,“*.pdf”)
Always good to search for similar topics too. Here’s a similar one:
How to find files in folders? - #6 by kiepnt
Thanks for your response. The topic you shared gave me the idea
Directory.GetFiles(“C:\Primary”,“*.pdf”,SearchOption.AllDirectories) – This works
Also I was exploring yesterday and found an activity - Get Files , search type = All Directories
Package - UiPath.DirectorySearch.Activity
fileList var should of type - List of String
Thanks for your reply but this will be bit time consuming.
this should be fine. Just for your information
This will be more useful. Thank you for sharing