I am creating a list of subdirectories on a server that all have one subfolder name in common. The server isn't identified by a drive letter, but by a name. So, my current code is something like this:
List<string> directories = new List<string>();
directories.Add(@"\\homeserv\Data\CompanyA\ABCD");
directories.Add(@"\\homeserv\Data\CompanyB\ABCD");
...
directories.Add(@"\\remoteserv\data\CompanyC\Eastern\ABCD");
This is okay with only a few subdirectories, but what if we had hundreds? We don't want to hard-code all these subdirectories into the program. Is there a way to search all subdirectories on a server for similar names (ex: "ABCD"), and put all those subdirectory names into a List?
I found the following code, but it seems to want a drive letter (ex: "C:\" and isn't working with a server name (ex: "\homeserv").
string[] dirs = Directory.GetFiles(@"\\homeserv\", "ABCD");
Thank you!