1. 程式人生 > 其它 >Delphi 2010 新增功能之: IOUtils 單元(6): TPath(結構體) 的方法與屬性

Delphi 2010 新增功能之: IOUtils 單元(6): TPath(結構體) 的方法與屬性

Delphi 2010 新增功能之: IOUtils 單元(6): TPath(結構體) 的方法與屬性


以後路徑相關的處理, 用 IOUtils.TPath 就很方便了.

//較常用的方法:
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 下是 ":"}