My path is \\\\server\\folderName1\\another name\\something\\another folder\\
\\\\server\\folderName1\\another name\\something\\another folder\\
How do I extract each folder name into a string if I don\'t know how many
DirectoryInfo objDir = new DirectoryInfo(direcotryPath); DirectoryInfo [] directoryNames = objDir.GetDirectories("*.*", SearchOption.AllDirectories);
This will give you all the directories and subdirectories.