我有一些路 c:\server\folderName1\another name\something\another folder\
.
我怎么能从那里提取最后一个文件夹名称?
我尝试了几件事,但他们没有用.
我只是不想搜索最后一个\
,然后采取其余的.
谢谢.
hal*_*lie 16
string a = new System.IO.DirectoryInfo(@"c:\server\folderName1\another name\something\another folder\").Name;
Run Code Online (Sandbox Code Playgroud)
using System;
using System.IO;
class Test
{
static void Main()
{
DirectoryInfo info = new DirectoryInfo("c:\\users\\jon\\test\\");
Console.WriteLine(info.Name); // Prints test
}
}
Run Code Online (Sandbox Code Playgroud)