1、c#根据绝对路径获取 带后缀文件名、后缀名、文件名。

 

 
1                 string str =" F:\test\Default.aspx";
2                 string filename = System.IO.Path.GetFileName(str);//文件名 “Default.aspx”
3                 string extension = System.IO.Path.GetExtension(str);//扩展名 “.aspx”
4                 string fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(str);// 没有扩展名的文件名 “Default”
5 
6                 string directory=System.IO.Path.GetDirectoryName(physicalPath);
 

2、c#根据绝对路径获取 带后缀文件名、后缀名、文件名,使用 Split 函数。

1                 string str = =" F:\test\Default.aspx";
2                 char[] delimiterChars = { '.', '\\' };
3                 string[] Mystr = str.Split(delimiterChars);
4                 string sheetName = Mystr[Mystr.Length - 2];);// 没有扩展名的文件名 “Default”
 

相关文章:

  • 2022-12-23
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-12
  • 2021-11-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案