SPECIAL OFFER        Order and save right now!
20% off with the 729824315 dicscount code for Ultimate Pack and any another product for Delphi from Greatis Programming!

⤷ Get full path to the file

GetLongName function allows you to get a full path to the file, using short path of this file. For example, if you have a 'C:\PROGRA~1' string, then you will get 'C:\Program Files' string.

function GetLongName(Path: string): string;

  function Check(St: string): string;
  var
    MyS: TSearchRec;
  begin
    FindFirst(St, faAnyFile, MyS);
    Result:=MyS.Name;
  end;

var
  P: Integer;
  Str, Res: string;
begin
  Res:='';
  P:=Pos('\', Path);
  Str:=Copy(Path, 1, P);
  Delete(Path, 1, P);
  Res:=Str;
  repeat
    P:=Pos('\', Path);
    if P>0 then
    begin
      Str:=Str+Copy(Path, 1, P-1);
      Delete(Path, 1, P);
      Res:=Res+Check(Str)+'\';
      Str:=Str+'\';
    end
    else
    begin
      Str:=Str+Path;
      Res:=Res+Check(Str);
    end;
  until P<=0;
  Result:=Res;
end;
Related components
TFileSearch
TFolderMonitor
TFileVersion
More for developers
Databases for Amazon Associates
Amazon Categories
Amazon Nodes