zoukankan      html  css  js  c++  java
  • C# 获取文件名、目录、后缀、无后缀文件名、扩展名

    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:

  • 相关阅读:
    P3811乘法逆元
    P4549裴蜀定理
    备用代码区
    其他板子整理
    DP
    图论板子整理
    约数
    浅谈假学习假努力
    质数
    P1019 单词接龙
  • 原文地址:https://www.cnblogs.com/LCLBook/p/10922217.html
Copyright © 2011-2022 走看看