Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to remove the file name from this file path...

Eg:- D:\Official\JitheshA\Projects\TestingTool\Attachments\1099\1081\Chrysanthemum.jpg


ANS: D:\Official\JitheshA\Projects\TestingTool\Attachments\1099\1081\


Regards
Jithesh A
Posted

Try:
C#
string fullPath = @"D:\Official\JitheshA\Projects\TestingTool\Attachments\1099\1081\Chrysanthemum.jpg";
string pathOnly = Path.GetDirectoryName(fullPath);
 
Share this answer
 
You want to get the directory name.

Path.GetDirectoryName will help you.
e.g.
C#
string directory = Path.GetDirectoryName(fileName);

Please have a look here for more examples:
http://www.dotnetperls.com/path[^]
 
Share this answer
 

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