티스토리 뷰

Programming/Delphi

Delphi Tip - 디렉토리 문자열 분리

파란크리스마스 2010. 4. 4. 06:31
728x90


uses
  StrUtils;

procedure TForm1.Button1Click(Sender: TObject);
var
  tmpDirStr : String;
  offset : integer;

  function GetFindStr(SubFindStr : String; var offset : integer):string;
  var
    offsetOld, offset2 : integer;
  begin
    Result := '';

    offset2 := 0;
    if SubFindStr[offset] = '/' then
      inc(offset2);

    offsetOld := offset;
    offset := PosEx('/', SubFindStr, offset + offset2);

    if offset>0 then begin
      Result := MidStr(SubFindStr, offsetOld + offset2, offset-offsetOld-offset2);
    end;
  end;

begin
  tmpDirStr := Edit1.Text;

  if (tmpDirStr[Length(tmpDirStr)]<>'/') then
    tmpDirStr := tmpDirStr + '/';

  offset := 1;

  while (offset > 0) do begin
    Memo1.Lines.Add(GetFindStr(tmpDirStr, offset));
  end;
end;

댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함