zoukankan      html  css  js  c++  java
  • 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:
  • 相关阅读:
    WAMPP安装后mysql无法启动
    转:xampp-php5.6下安装memcached.exe
    apache配置多域名多站点记录
    抽象类
    this关键字
    static关键字
    super关键字
    Set
    Map
    List
  • 原文地址:https://www.cnblogs.com/vip-ygh/p/3620808.html
Copyright © 2011-2022 走看看