C#获取路径中最后一个文件夹的名字

 1 using System;
 2 using System.IO;
 3 
 4 namespace ConsoleApplication1
 5 {
 6     class Program
 7     {
 8         static void Main(string[] args)
 9         {
10             string path1 = @"E:\uniuProject5.6.2\art\UnityArt(u3d5.6.2)\Assets\Cloth\FBX\Character\Models";
11             string path2 = @"E:\uniuProject5.6.2\art\UnityArt(u3d5.6.2)\Assets\Cloth\FBX";
12             string path3 = @"E:\uniuProject5.6.2\art\UnityArt(u3d5.6.2)";
13             string path4 = @"E:\uniuProject5.6.2\art\UnityArt(u3d5.6)lklk";
14 
15             Console.WriteLine(Path.GetFileNameWithoutExtension(path1));
16             Console.WriteLine(Path.GetFileNameWithoutExtension(path2));
17             Console.WriteLine(Path.GetFileNameWithoutExtension(path3));
18             Console.WriteLine(Path.GetFileNameWithoutExtension(path4));
19 
20             Console.ReadKey();
21         }
22     }
23 }

打印结果:

posted @ 2018-11-15 14:14  小·糊涂仙  阅读(10551)  评论(0编辑  收藏  举报