Examples Delphi

function GetParentDirName(dirName: String): String;
function TMainForm.GetParentDirName(dirName: String): String;
var
tempArray: array[0..100] of Char;
idx1, idx2, slashCount: Integer;
begin
for idx1 := 0 to (Length(dirName) - 1) do
begin
tempArray[idx1] := dirName[idx1 + 1];
end;
slashCount := 0;
for idx2 := idx1 downto 0 do
begin
if (tempArray[idx2] = '\') then Inc(slashCount);
if (slashCount = 2) then break;
tempArray[idx2] := #0;
end;
Result := String(tempArray);
end;