-
string filepath = “c:\\1.txt”;
-
string str = “获取文件的全路径:” + path.getfullpath(filepath); //–>c:1.txt
-
str = “获取文件所在的目录:” + path.getdirectoryname(filepath); //–>c:
-
console.writeline(str);
-
str = “获取文件的名称含有后缀:” + path.getfilename(filepath); //–>1.txt
-
str = “获取文件的名称没有后缀:” + path.getfilenamewithoutextension(filepath); //–>1
-
str = “获取路径的后缀扩展名称:” + path.getextension(filepath); //–>.txt
-
str = “获取路径的根目录:” + path.getpathroot(filepath); //–>c:\
黄山市民网:https://www.huangshanshimin.com/