Get Directory name from full path of file?
I am new to C#, please help me to get the directory name from full path of a file, say
D:\Projects\ProjectName\CarDocuments\CarBook.pdf
2 Answers
use .DirectoryInfo(path).Name to get the directory Name
String dirName = new System.IO.DirectoryInfo(path).Name;
|
0
|
Answered:
04 Mar 2013
Reputation: 242
|
|
Check this by using FileInfo
FileInfo fileInfo = new FileInfo(path);
String dirName = fileInfo.Diretory.Name;
|
0
|
Answered:
04 Mar 2013
Reputation: 296
|
|
This week users
