zoukankan      html  css  js  c++  java
  • C#Path目录路径常用操作

    经常百度这个问题,经常记不住,以下是笔记:

    参考:https://blog.csdn.net/u011976734/article/details/79654399

    定义 string filePath =@"E:/project/test/20180322.jpg";

     方法  方法说明  结果
    System.IO.Path.ChangeExtension(filePath, "txt")  更改路径字符串的扩展名 E:/project/test/20180322.txt
    System.IO.Path.GetDirectoryName(filePath) 返回指定路径字符串的目录信息 E:/project/test/
    System.IO.Path.GetExtension(filePath)  返回指定的路径字符串的扩展名  .jpg
    System.IO.Path.GetFileName(filePath)  返回指定路径字符串的文件名和扩展名 20180322.jpg
    System.IO.Path.GetFileNameWithoutExtension(filePath)  返回不具有扩展名的指定路径字符串的文件名  20180322
    System.IO.Path.GetPathRoot(filePath) 获取指定路径的根目录信息  E:/
    System.IO.Path.GetRandomFileName() 返回随机文件夹名或文件名   ct2h5b2h.sed
    System.IO.Path.GetTempFileName()  创建唯一命名的零字节的临时文件并返回其绝对路径  C:/Documents and Settings/Randy/Local Settings/Temp/tmpAD.tmp
    System.IO.Path.GetTempPath()  返回当前系统的临时文件夹的路径  C:/Documents and Settings/Randy/Local Settings/Temp/
    System.IO.Path.HasExtension(filePath) 返回路径是否包括文件扩展名   True
    System.IO.Path.IsPathRooted(filePath) 返回路径是绝对路径还是相对路径 Ture
    System.IO.Path.Combine(@ "c: ", "b.txt ")  返回合并后的路径  C:/b.txt
    System.IO.Path.GetFullPath("20180322.jpg")  查找文件并返回其绝对路径
    E:/project/test/20180322.jpg
         
  • 相关阅读:
    e552. 取Applet的参数
    e551. 精简的Applet
    e558. 在Applet中多图片交互显示
    e1087. try/catch语句
    e1086. if/else语句
    e1087. 用For循环做数组的遍历
    e1084. 捕获错误和异常
    Zookeeper 应用程序
    Zookeeper API
    Java并发编程:volatile关键字解析
  • 原文地址:https://www.cnblogs.com/baozi789654/p/15760731.html
Copyright © 2011-2022 走看看