My path is \\\\server\\folderName1\\another name\\something\\another folder\\
How do I extract each folder name into a string if I don\'t know how many
Realise this is an old post, but I came across it looking - in the end I decided apon the below function as it sorted what I was doing at the time better than any of the above:
private static List SplitDirectory(DirectoryInfo parent)
{
if (parent == null) return null;
var rtn = new List();
var di = parent;
while (di.Name != di.Root.Name)
{
rtn.Add(new DirectoryInfo(di));
di = di.Parent;
}
rtn.Add(new DirectoryInfo(di.Root));
rtn.Reverse();
return rtn;
}