当前位置: 代码迷 >> 综合 >> C# 通过文件路径获取文件名
  详细解决方案

C# 通过文件路径获取文件名

热度:10   发布时间:2024-02-26 18:39:55.0
string fullPath = @"c:\test.jpg";string filename = System.IO.Path.GetFileName(fullPath);//文件名  “test.jpg”
string extension = System.IO.Path.GetExtension(fullPath);//扩展名 “.jpg”
string fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(fullPath);// 没有扩展名的文件名 “test”

 

  相关解决方案