Q&A

  • 서브목록
.
1  COMMENTS
  • Profile
    홍성락 2002.11.07 20:02
    바로 밑의 폴더목록만 구하는거는
    procedure TForm1.Button2Click(Sender: TObject);
    var
        SearchRec: TSearchRec;
    begin
        if FindFirst('C:HSR_JOB응용소스스트링 디비 그리드' + '*.*', faAnyFile , SearchRec) = 0 then begin
          repeat
             if (SearchRec.Attr and FaVolumeId <> FaVolumeID) then begin
                if (SearchRec.Attr and FaDirectory = FaDirectory) then begin
                    if (SearchRec.Name <> '.')and(SearchRec.Name <> '..') then
                       Form1.ListBox1.Items.Add(SearchRec.Name);
                end;
             end;
          until FindNext(SearchRec) <> 0;
          FindClose(SearchRec);
        end;
    end;

    그리고 하위의 하위를 계속 찾는건 재귀호출을 쓰시면 됩니다.
    procedure FileExtSearch(DirectoryList:string);
    var
        SearchRec: TSearchRec;
    begin
        if FindFirst(DirectoryList + '*.*', faAnyFile , SearchRec) = 0 then begin
          repeat
             if (SearchRec.Attr and FaVolumeId <> FaVolumeID) then begin
                if (SearchRec.Attr and FaDirectory = FaDirectory) then begin
                    if (SearchRec.Name <> '.')and(SearchRec.Name <> '..') then begin
                       Form1.ListBox1.Items.Add('[폴더]' + DirectoryList + '' +SearchRec.Name);
                       FileExtSearch(DirectoryList + '' + SearchRec.Name);
                    end;
                end
                else begin
                   Form1.ListBox1.Items.Add('[' + DirectoryList + ']' +SearchRec.Name);
                end;
             end;
          until FindNext(SearchRec) <> 0;
          FindClose(SearchRec);
        end;
    end;


    procedure TForm1.Button1Click(Sender: TObject);
    begin
        ListBox1.Clear;
        FileExtSearch('C:HSR_JOB응용소스스트링 디비 그리드');  //
    end;
    hsr//////////////////////////////////////////////////////////