LCLBook
  1. string filePath = "C:\\1.txt";

  2. string str = "获取文件的全路径:" + Path.GetFullPath(filePath); //-->C:1.txt

  3. str = "获取文件所在的目录:" + Path.GetDirectoryName(filePath); //-->C:

  4. Console.WriteLine(str);

  5. str = "获取文件的名称含有后缀:" + Path.GetFileName(filePath); //-->1.txt

  6. str = "获取文件的名称没有后缀:" + Path.GetFileNameWithoutExtension(filePath); //-->1

  7. str = "获取路径的后缀扩展名称:" + Path.GetExtension(filePath); //-->.txt

  8. str = "获取路径的根目录:" + Path.GetPathRoot(filePath); //-->C:\

分类:

技术点:

相关文章:

  • 2021-09-07
  • 2021-10-20
  • 2021-12-31
  • 2021-11-13
  • 2022-01-08
  • 2021-12-10
  • 2021-09-26
  • 2021-10-16
猜你喜欢
  • 2021-12-10
  • 2021-12-10
  • 2021-11-22
  • 2021-10-20
  • 2021-10-20
  • 2021-11-27
相关资源
相似解决方案