从路径获取文件夹名称 [英] Get a folder name from a path

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

问题描述

我有一些路径 C:\server\folderName1\another name\something\another folder\



我怎样才能从那里最后一个文件夹的名字吗?



我已经试过几件事,但他们没有工作。

$提取b
$ b

我只是不希望搜索最后 \ ,然后拿剩下的。



感谢。


解决方案

 串=新的系统。 IO.DirectoryInfo(@C:\server\folderName1\another name\something\another folder\)名称。 


I have some path c:\server\folderName1\another name\something\another folder\ .

How i can extract from there the last folder name ?

I have tried several things but they didn't work.

I just don't want to search for the last \ and then to take the rest .

Thanks.

解决方案

string a = new System.IO.DirectoryInfo(@"c:\server\folderName1\another name\something\another folder\").Name;

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

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