Capture just the foldername from directory structure

Good day all,

I have read and tried every possible solution from this forum, as well as from the MS VB.Net forum, but to no avail.

I need to capture just the folder name, and not the whole path, of the folders underneath this structure:
“P:\W09_Bodyshop\02_Steering\Team\11_Central_Maintenace\02_Personnel folders\10_Kulani Valoyi\Single pictures”. Those foldernames are typically MS0000xx.
This folderpath has already been assigned to an argument as well: IN_STR_FILEEXPLORER_FOLDERNAME.

I have then tried to create a string called ArrayFolder, with an Assign activity. This ArrayFolder’s function is System.IO.Directory.GetDirectories(IN_STR_FILEEXPLORER_FOLDERNAME,“,”*", System.IO.SearchOption.AllDirectories)
This all just runs and runs, and nothing happens.

I basically need all of these folder names in a datatable, to be sent to the Queue.

Please assist.

Hi, the System.IO.Directory.GetDirectories method with the System.IO.SearchOption.AllDirectories option should return an array with all paths to your folders. After that you can simply use split(""c).Last on each folder path to retrieve only the name and add it to your datatable.
test.xaml (6.7 KB)

1 Like

@herman - This query will print only the folder names without the path…

Directory.GetDirectories("YourFolderPath").select(Function(x) new fileinfo(x).Name).ToArray()

Try and let us know…

This is my folder structure


And this is output printing without path…


Thanks - this has worked like a charm!

1 Like

Thanks, but the solution just below was a bit simpler!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.