this slowpoke moves

Get Folder Name from Path

function ExtractDirName(Path:string):string;
var
  i:integer;
begin
  // Check if last Char is \
  if Pos('\', Path[Length(Path)]) = 1 then
    Path:=Copy(Path,1,Length(Path) - 1);
  // ExtractDirName
  for i:=Length(Path) downto 0 do
    if Pos('\', Path[i]) = 1 then
    begin
      Result:=Copy(Path,i+1,Length(Path)-i);
      Exit;
    end;
end;
Beispiel :
procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage(ExtractDirName('c:/Programme/Adobe/'))
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate