Conversion between absolute and relative paths in Delphi

后端 未结 9 528
不思量自难忘°
不思量自难忘° 2020-11-30 01:18

Are there standard functions to perform absolute <--> relative path conversion in Delphi?

For example:

  • \'Base\' path is \'C:\\Projects\\Projec
9条回答
  •  余生分开走
    2020-11-30 01:44

    Another version of RelToAbs (compatible with all Delphi XE versions).

    uses
      ShLwApi;
    
        function RelPathToAbsPath(const ARelPath, ABasePath: string): string;
        var Buff:array[0..MAX_PATH] of Char;
        begin
          if PathCombine(Buff, PChar(IncludeTrailingPathDelimiter(ABasePath)), PChar(ARelPath)) = nil then
            Result := ''
          else Result:=Buff;
        end;
    

提交回复
热议问题