Click here to Skip to main content
15,879,613 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
hi everyone,For example i have a file ISample.cs in this path like "D:\TEST_SOURCE\CV\SOURCE CODE\ARMY.Data\ProceduresALL\ISample.cs".Here i wanna the file-path from "ProceduresAll\ISample.cs".Before that i don't wanna that path.Here i am using folder browser for choosing the folder.Please help me regarding this.
Posted

The following the perfect answer
MIDL
string path = @"D:\TEST_SOURCE\CV\SOURCE CODE\ARMY.Data\ProceduresALL\ISample.cs";
//ISample.cs
Path.GetFileName(path);
//D:\TEST_SOURCE\CV\SOURCE CODE\ARMY.Data\ProceduresALL
Path.GetDirectoryName(path);
//ProceduresALL
Path.GetDirectoryName(path).Split(Path.DirectorySeparatorChar).Last();
 
Share this answer
 
Comments
sujeet101 1-Dec-10 6:53am    
good job..
Dalek Dave 1-Dec-10 7:24am    
Good Answer!
Have you tried to use the File Info Class to get this info.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900