码迷,mamicode.com
首页 > 其他好文 > 详细

System.IO.Path 文件名、路径、扩展名 处理

时间:2016-01-09 00:57:42      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:

string filePath =@"E:/Randy0528/中文目录/JustTest.rar";

更改路径字符串的扩展名。
System.IO.Path.ChangeExtension(filePath, "txt");
E:/Randy0528/中文目录/JustTest.txt

返回指定路径字符串的目录信息。
System.IO.Path.GetDirectoryName(filePath);
E:/Randy0528/中文目录

返回指定的路径字符串的扩展名。
System.IO.Path.GetExtension(filePath);
.rar

返回指定路径字符串的文件名和扩展名。
System.IO.Path.GetFileName(filePath);
JustTest.rar

返回不具有扩展名的指定路径字符串的文件名。
System.IO.Path.GetFileNameWithoutExtension(filePath);
JustTest

获取指定路径的根目录信息。
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);
True

转载:http://blog.csdn.net/chanyinhelv/article/details/8432840

System.IO.Path 文件名、路径、扩展名 处理

标签:

原文地址:http://www.cnblogs.com/spring-sd/p/5115271.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!