在FMX中,可以使用TPath.GetRelativePath函数来实现类似于VCL.MinimizeName函数的功能。它接收两个字符串参数:Base和Target,可以根据Base路径将Target路径相对化并缩短路径名。示例如下:
uses
System.IOUtils;
var
BasePath, TargetPath, MinimizedPath: string;
begin
BasePath := 'C:\Project\Source';
TargetPath := 'C:\Project\Source\Subfolder\Filename.pas';
MinimizedPath := TPath.GetRelativePath(BasePath, TargetPath);
// MinimizedPath = 'Subfolder\Filename.pas'
end;
在上面的示例中,BasePath为基础路径,TargetPath为目标路径,通过调用TPath.GetRelativePath函数并将它们传递给函数,可以得到相对路径并缩短路径名。