Deeipauk
(Deeipauk RS)
September 14, 2020, 10:42am
1
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
1.) C:\Primary\test1.pdf
2.) C:\Primary\SubFolder1\test2.pdf
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.
Hi,
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”)
1 Like
mircea
(Mircea Grigore)
September 15, 2020, 6:48pm
3
Always good to search for similar topics too. Here’s a similar one: How to find files in folders? - #6 by kiepnt
2 Likes
Deeipauk
(Deeipauk RS)
September 16, 2020, 7:54am
4
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
1 Like
Deeipauk
(Deeipauk RS)
September 16, 2020, 7:56am
5
Thanks for your reply but this will be bit time consuming.
Directory.GetFiles(“C:\Primary”,“*.pdf”,SearchOption.AllDirectories)
this should be fine. Just for your information
2 Likes
This will be more useful. Thank you for sharing