Search code examples
c#directory

Get folder name from full folder path


How do I get the folder name from the full path of the application?

This is the file path below,

c:\projects\root\wsdlproj\devlop\beta2\text

Here "text" is the folder name.

How can I get that folder name from this path?


Solution

  • See DirectoryInfo.Name:

    string dirName = new DirectoryInfo(@"c:\projects\roott\wsdlproj\devlop\beta2\text").Name;