SyntaxFix
Write A Post
Hire A Developer
Questions
Try this:
string filename = @"C:/folder1/folder2/file.txt"; string FolderName = new DirectoryInfo(System.IO.Path.GetDirectoryName(filename)).Name;