使用函数:
System.IOUtils.TDirectory.IsRelativePath
class function IsRelativePath(const Path: string): Boolean; inline; static;
异常处理:无,纯粹判断路径,与目录是否存在无关
代码:
begin
// 判断指定目录是否为相对路径
try
if (TDirectory.IsRelativePath(Trim(Edit1.Text))) then
ShowMessage(Edit1.Text + '是相对路径')
else
ShowMessage(Edit1.Text + '不是相对路径');
except
on e: Exception do
begin
MessageDlg(e.ClassName + ' : ' + e.Message, mtError, [mbok], );
Exit;
end;
end;
end;