I need to get the last part of current directory, for example from /Users/smcho/filegen_from_directory/AIRPassthrough, I need to get AIRPassthrough
/Users/smcho/filegen_from_directory/AIRPassthrough
AIRPassthrough
var lastFolderName = Path.GetFileName( path.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar));
This works if the path happens to contain forward slash separators or backslash separators.