Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a folder name from a path

Tags:

c#

I have some path c:\server\folderName1\another name\something\another folder\ .

How i can extract from there the last folder name ?

I have tried several things but they didn't work.

I just don't want to search for the last \ and then to take the rest .

Thanks.

like image 226
Night Walker Avatar asked Mar 09 '10 09:03

Night Walker


1 Answers

string a = new System.IO.DirectoryInfo(@"c:\server\folderName1\another name\something\another folder\").Name;
like image 191
hallie Avatar answered Oct 09 '22 09:10

hallie