Извиняюсь, что без комментариев.
| Код | procedure TForm1.Button2Click(Sender: TObject);
function AllEquals(const sl: TStrings): Boolean; var i: Integer; begin Result := False; for i := 0 to sl.Count - 2 do begin if sl.Strings[i] <> sl.Strings[i+1] then Exit; end;
Result := True; end;
procedure DeleteLast(const sl: TStrings); var i, p: Integer; begin for i := 0 to sl.Count - 1 do begin if sl.Strings[i][Length(sl.Strings[i])] = '\' then sl.Strings[i] := Copy(sl.Strings[i], 1, Length(sl.Strings[i]) - 1);
p := LastDelimiter('\', sl.Strings[i]); sl.Strings[i] := Copy(sl.Strings[i], 1, p); end; end; begin while not AllEquals(ListBox1.Items) do DeleteLast(ListBox1.Items); end; |
Добавлено @ 15:44 Мой ListBox:| Цитата | C:\Documents and Settings\Yanis123\Cookies\yanis@nnm[1].txt C:\Documents and Settings\Yanis\Cookies\yanis@spylog[2].txt C:\Documents and Settings\Yanis\Cookies\yanis@empo[1].txt C:\Documents and Settings\Yanis\Cookies\[email protected][2].txt C:\Documents and Settings\Yanis\Cookies\[email protected][2].txt |
Результат:| Цитата | C:\Documents and Settings\ C:\Documents and Settings\ C:\Documents and Settings\ C:\Documents and Settings\ C:\Documents and Settings\ |
|