How to find the path of a specific deep subdirectory with only the subdirectory's name?

I want to move a file into a subdirectory. The subdirectory is within several subdirectories. I have only the name of the parent directory and the name of the subdirectory that I want the file to go into. I do not know the subdirectories in-between the parent directory and destination subdirectory and need to find where that subdirectory is with its absolute path so I can then move the file into that subdirectory.

@path1

Use Directory.GetDirectories to get the subdirectories of the directory. The result is in array of strings.

Var Directories = Directory.GetDirectories(“your directory path”)

string folders = System.IO.Directory.GetDirectories(@“C:\My Sample Path”,"*", System.IO.SearchOption.AllDirectories);

Thanks,
Aman

Are these two separate solutions?

@path1

You can try second one which is mentioned above.
string folders = System.IO.Directory.GetDirectories(@“C:\My Sample Path”,"*", System.IO.SearchOption.AllDirectories);

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