Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
How can I get the Folder Path from a file path in C#?

Filepath: "C:\\mydir\\myfile.ext"

I need the Folder Path as : "C:\\mydir\\"
Posted
Updated 17-Oct-11 18:50pm

Hi

This may be help you

http://stackoverflow.com/questions/660657/parse-directory-name-from-full-filepath-in-c-sharp

or
http://www.dotnetperls.com/path

so you will get the idea


Thanks
 
Share this answer
 
v2
Comments
RAJI @Codeproject 18-Oct-11 1:13am    
thanks..i got it

string folderPath = new FileInfo(filePath).DirectoryName;
shijuse 18-Oct-11 1:15am    
ok Raji
 
Share this answer
 
As simple as this:

C#
string directoryName = System.IO.Path.GetDirectoryName(filePath);


See http://msdn.microsoft.com/en-us/library/system.io.path.aspx[^].

—SA
 
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