Delphi Tips&Tricks News   Tips   .NET Software   VCL Software   Search   Contacts
Ultimate Pack - special offer!

Ultimate Pack  hot!
Image Editor  new!
Runtime Fusion
Form Designer
Object Inspector
Print Suite Pro
Commented Image
Delphi Toys
WinDowse
Delphi Bonus
TMS Scripter Studio
Form Designer VB
Form Designer .NET

...get more...
for Delphi.NET, C#, VB.NET
for Delphi VCL, BCB 3-6

WinAPI Online
Unix Manual Pages
MegaDetailed.NET
in3steps.com
cdtrrracks.com new!

Blogspot  greatis.blogspot.com

Get full path to the file - Files & folders - Tips & Tricks - Greatis Delphi Pages

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 topics
Get short path to the file

For more
Delphi Help

Download source