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.2artUnityArt(u3d5.6.2)AssetsClothFBXCharacterModels"; 11 string path2 = @"E:uniuProject5.6.2artUnityArt(u3d5.6.2)AssetsClothFBX"; 12 string path3 = @"E:uniuProject5.6.2artUnityArt(u3d5.6.2)"; 13 string path4 = @"E:uniuProject5.6.2artUnityArt(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 }
打印结果: