标签:info mp4 new lin 拼接 direct ext 变量 pat
var filePath = @"c:\doc\1.txt";
var dirPath1 = @"c:\music\";
var dirPath2 = @"c:\movie";
Console.WriteLine(Path.Combine(dirPath1, "a.mp3")); //c:\music\a.mp3
Console.WriteLine(Path.Combine(dirPath2, "b.mp4")); //c:\movie\b.mp4
Console.WriteLine(Path.GetDirectoryName(dirPath1)); //c:\music
Console.WriteLine(Path.GetDirectoryName(dirPath2)); //c:Console.WriteLine(Path.GetDirectoryName(filePath)); //c:\doc
Console.WriteLine(new DirectoryInfo(dirPath1).Name); //music
Console.WriteLine(new DirectoryInfo(dirPath2).Name); //movie
Console.WriteLine(new DirectoryInfo(@"d:\a\b\c\d").Parent.Name); //c
Console.WriteLine(Path.GetFileName(filePath)); //1.txt
Console.WriteLine(Path.GetFileNameWithoutExtension(filePath)); //1
Console.WriteLine(Path.GetExtension(filePath)); //.txt
标签:info mp4 new lin 拼接 direct ext 变量 pat
原文地址:https://www.cnblogs.com/trykle/p/14505546.html