//一个文件目录string
string filePath = "C:\\1.txt";it
string str = "获取文件的全路径:" + Path.GetFullPath(filePath); //-->C:1.txtio
str = "获取文件所在的目录:" + Path.GetDirectoryName(filePath); //-->C:扩展
Console.WriteLine(str);file
str = "获取文件的名称含有后缀:" + Path.GetFileName(filePath); //-->1.txt文件
str = "获取文件的名称没有后缀:" + Path.GetFileNameWithoutExtension(filePath); //-->1
str = "获取路径的后缀扩展名称:" + Path.GetExtension(filePath); //-->.txt
str = "获取路径的根目录:" + Path.GetPathRoot(filePath); //-->C:\