举例 定义 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) | 返回路径是否包括文件扩展名 | Ture |
System.IO.Path.IsPathRooted(filePath) | 返回路径是绝对路径还是相对路径 | Ture |
System.IO.Path.Combine(@ "c: ", "b.txt ") | 返回合并后的路径 | C:/b.txt |
System.IO.Path.GetFullPath("JustTest.rar") | 查找文件并返回其绝对路径 | E:/Randy0528/中文目录/JustTest.rar |