Directory of directory

how to get files from directory of directory
any thing like directory.directory.getfiles?

@Sakshi_Jain - You mean subfolders??

yes
folder1 > folder 2> files

like
D:/folder/folder1/file1
D:/folder/folder1/file2
D:/folder/folder1/file3
D:/folder/folder1/file4
D:/folder/folder1/file5
D:/folder/folder1/file6
D:/folder/folder1/file7

D:/folder1/folder2/file8
D:/folder/folder2/file9
D:/folder/folder2/file10
D:/folder/folder2/file11
D:/folder/folder2/file12

D:/folder1/folder3/file13
D:/folder/folder3/file14
D:/folder/folder3/file15
D:/folder/folder3/file16
D:/folder/folder1/file1

also i can specify filter for files like “.pdf" or ".xlsx” or “*.msg”

Hi @Sakshi_Jain !
What about this line ?
Directory.GetFiles("C:\\path", "*.*", SearchOption.AllDirectories).Where(Function(j) j.EndsWith(".pdf") or j.EndsWith(".xlsx") or j.EndsWith(".msg")).ToArray
Dont forget to do so:

Let us know how does it work for you !

1 Like

Can I get both filename and folder names ?

yes you will get in the array of string all the absolute paths (= including filename + foldername)

@Hiba_B
how do you learn the linq queries?
For example below
i went through the below link , but whatever they have mentioned doesnot match with our UiPath Linq…

There is no similarity…
which ever linq query i see they look so different , so could you tell me where i can get some linq qeries tutorials to implement in uipath

Below query will just give the folder names of the files found…

Directory.GetFiles("YourFolderPath").Where(Function(j) 
j.EndsWith(".pdf") or j.EndsWith(".xlsx") or j.EndsWith(".msg")).Select(function(x) new 
fileinfo(x).DirectoryName).ToArray()

Hi @Seema_S !
Personally I learn from ppr in his links like this one, I really recommend you to go through his detailed explanations + his sources !!! :grinning_face_with_smiling_eyes:

1 Like

Did it work for you @Sakshi_Jain ?

@Hiba_B
Thanks for the link. Yeah **ppr** seems to be highly expert in Linq.
Thanks for the linq.
Also do you have some more study materials. Please post it, it will be more useful
Thank u :slight_smile:

for people who don’t know .net, there’s a studio x activity now that does the same thing

image

1 Like

@nameless - yes, this is good option if you are looking for extracting only extension from the folder…if you are looking for multiple extension(Say (pdf or xlsx) or (pdf or xlsx or docx) this wont be helpful…

add an if condition in the loop for that, which is basically what a linq query will do. Like i said, it’s for novice devs.