i have 3 Folders where i have some files in each folders, now by doing directory.getfiles i have 3 array variables for 3 folders, i want to put these 3 array under one for each, so under one for each 1st array would be taken then whatever the number of files present in that array some action will be performed in it then 2nd array then 3rd array. any idea how this can be achieved?
Directory.GetFiles returns the files in the Folder, not the Subfolders
You can use the below expression to get the xlsx files from these 3 Subfolders.
Suppose you have 3 sub folders
Folder 1 - Has Files of Structure Folder1\Test1.xlsx ,Folder1\Test2.xlsx
Folder 2 - Has Files of Structure Folder2\Test1.xlsx ,Folder2\Test2.xlsx
Folder 3 - Has Files of Structure Folder2\Test1.xlsx ,Folder2\Test2.xlsx
Then in the above expression needs to be modified like this
So the above will give all the files from Folder1 and the same needs to done for other folders
yeah but in my case i need to process 3 folder differently, it’s not like i want to take all files at once from those 3 folders, i need all files from 1 folder then goto another one then another one(because of some different process), that’s why i was talking about passing it under one for each
So When you use this
Directory.GetFiles(“D:\Projects”,“ Folder1 .xlsx”,SearchOption.AllDirectories), you will get array of files for folder 1 and you perform the actions and same with other 2 folders.
Its just you will be using multiple for each for performing actions on different folders