If i have:
C:\\temp\\foo\\bar\\
(NOTE: bar is a directory)
how can i parse out:
bar
The simplest way to do this without creating a new DirectoryInfo instance is to use the Path.GetFileName static method. This is located in System.IO.
using System.IO;
string lastFolderName = Path.GetFileName(@"C:\Folder1\Folder2");
The variable would be set to "Folder2".
This is quite a bit more efficient that creating a new instance of the DirectoryInfo class!