Q:

Looping through folders

How do I loop through folders inside an if statement. I want to tell the robot to search for filepath + row.item(0) + either one or double space + row.item(1).tostring? Some of the folders have double spaces and some have single space. Help is much appreciated.
Best regards

A:

to recursively get folders you can use the below method
GetDirectories(String, String, SearchOption)
If you use the following parameters you should be able to find your folders, the top method will return folders with one space the one below will return folders with two spaces.
Directory.GetDirectories(
    "C:\",
    filepath + row.item(0) + " " + row.item(1).tostring,
    SearchOption.AllDirectories)
Directory.GetDirectories(
    "C:\",
    filepath + row.item(0) + "  " + row.item(1).tostring,
    SearchOption.AllDirectories)
To combine this into a single line of code that can be used within an assign you can use the following.
Directory.GetDirectories("C:\",filepath + row.item(0) + " " + row.item(1).tostring,SearchOption.AllDirectories).AddRange(Directory.GetDirectories("C:\",filepath + row.item(0) + "  " + row.item(1).tostring,SearchOption.AllDirectories))
This will extract on list of directories with one space in then add the second list of directories to it with the double spaces in. This will give you a single list containing folders that match either of the search strings

