IOUtils 單元(6): TPath(結構體)路徑的提取和處理

來源:互聯網
上載者:User
之前複雜的ExtractFilePath 這類的函數總算有新的替換者了。
//較常用的方法:
TPath.GetTempPath;                  {擷取臨時檔案夾路徑}
TPath.GetTempFileName;              {擷取一個臨時檔案名稱}
TPath.GetPathRoot();                {提取盤符, 如: c:/}
TPath.GetDirectoryName();            {提取路徑}
TPath.GetFileName();                {提取檔案名稱}
TPath.GetExtension();                {提取副檔名}
TPath.GetFileNameWithoutExtension(); {提取無副檔名的檔案名稱}
TPath.ChangeExtension();            {更換副檔名}
TPath.DriveExists();                {檢查路徑中的磁碟機是否存在}
TPath.GetFullPath();                {根據相對路徑給出全路徑}
TPath.HasExtension();                {判斷是否有副檔名}
TPath.IsPathRooted();                {判斷是否是絕對路徑}
TPath.Combine();                    {結合路徑}
TPath.GetRandomFileName;            {產生一個隨機檔案名稱}
TPath.GetGUIDFileName();            {用於產生一個唯一的檔案名稱, 布爾參數決定名稱中是否包含 -}
TPath.IsValidPathChar();            {判斷給定的字元是否能用於路徑名}
TPath.IsValidFileNameChar();        {判斷給定的字元是否能用於檔案名稱}

//不常用的方法
TPath.HasValidPathChars();
TPath.HasValidFileNameChars();
TPath.GetExtendedPrefix();
TPath.IsExtendedPrefixed();
TPath.IsUNCRooted();
TPath.IsDriveRooted();
TPath.IsUNCPath();
TPath.MatchesPattern();
TPath.GetInvalidFileNameChars;
TPath.GetInvalidPathChars;
TPath.GetAttributes();
TPath.SetAttributes();

//屬性, 擷取在不同平台下的各種路徑分隔字元, 都是唯讀.
TPath.AltDirectorySeparatorChar;    {Windows 下是 "/"}
TPath.AltDirectorySeparatorChar;    {Windows 下是 "/"}
TPath.ExtensionSeparatorChar;        {Windows 下是 "."}
TPath.PathSeparator;                {Windows 下是 ";"}
TPath.VolumeSeparatorChar;          {Windows 下是 ":"}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.