C# 获取文件的后缀,文件名和路径

时间:2021-08-09 23:01:04   收藏:0   阅读:25

现有一个文件路径为:  localFilePath=”C:\Users\yhood\Desktop\林业局考勤06.xlsx“

 

 

string directory = Path.GetDirectoryName(localFilePath);    //文件所在路径      C:\Users\yhood\Desktop
  string filename = Path.GetFileNameWithoutExtension(localFilePath);    //文件名    林业局考勤06
  string extension = Path.GetExtension(localFilePath);      //文件后缀 带点(.)     .xlsx

 

原文:https://www.cnblogs.com/Kendy/p/15119984.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!