• C# 轻松获取路径中文件名、目录、扩展名等


    C# 轻松获取路径中文件名、目录、扩展名等    

    string path = "C:\dir1\dir2\foo.txt"; 

    string str = "GetFullPath:" + Path.GetFullPath(path) + " ";
     
    str += "GetDirectoryName:" + Path.GetDirectoryName(path) + " "; 
    str += "GetFileName:" + Path.GetFileName(path) + " "; 
    str += "GetFileNameWithoutExtension:" + Path.GetFileNameWithoutExtension(path) + " "; 
    str += "GetExtension:" + Path.GetExtension(path) + " "; 
    str += "GetPathRoot:" + Path.GetPathRoot(path) + " "; MessageBox.Show(str); 
    结果: 

    GetFullPath:C:dir1dir2foo.txt 
    GetDirectoryName:C:dir1dir2 
    GetFileName:foo.txt 

    GetFileNameWithoutExtension:foo 
    GetExtension:.txt 
    GetPathRoot:C: 

  • 相关阅读:
    Python的文本数据
    Python
    正则表达式
    多数据库的链接
    工作感受月记 201902月
    女儿的出生
    工作感受月记 201901月
    工作感受月记 201812月
    工作感受月记 201811月
    工作感受月记 201809
  • 原文地址:https://www.cnblogs.com/wangzuofei/p/7412727.html
Copyright © 2020-2023  润新知