舉例 定義 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 |