从文件路径获取文件夹路径 [英] Get Folder Path from a File Path

查看:106
本文介绍了从文件路径获取文件夹路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从C#中的文件路径获取文件夹路径?

文件路径:"C:\\ mydir \\ myfile.ext"

我需要的文件夹路径为:"C:\\ mydir \\"

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\\"

推荐答案



这可能对您有帮助

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


http://www.dotnetperls.com/path

这样您就会明白


谢谢
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


检查一下..

如何从完整文件路径获取文件名 [ ^ ]
Check this..

How to get File Name from Full file Path[^]


就这么简单:

As simple as this:

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



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

—SA



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

—SA


这篇关于从文件路径获取文件夹路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆