Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 Q&A
Delphi Programming Q&A
[10309] Re:[초보] 특정 폴더를 선택해서 하나의 그 안의 폴더와 각 폴더의 파일 갯수에 대해
civilian,안영제 [civilian] 1544 읽음    2005-10-24 21:43
디렉토리의 파일을 검색하려면 "재귀호출"을 써야 합니다.
즉, 디렉토리 내의 파일을 찾는 루틴을 만들고, 디렉토리가 발견되면
다시 그 함수를 부르는 방법을 써야 합니다.

raincode 님이 쓰신 글 :
: 선택한 폴더 안의 폴더 갯수와 그 특정 폴더의 파일 갯수를 구해서 매번 Oracle DB에 갱신을 해줄려고 하는데 계속 한 곳의 폴더에서만 갱신이 되는군요. 부탁좀 드리겠습니다. 그리고 그에 대해서 설명도 해주셨으면 좋겠구요.
:
: procedure Tfrm_Main.CountStringGrid_File(Path: String);
: var
:     sr: TSearchRec;
:   FileAttrs: Integer;
:   svSearch: TSearchRec;
:
:   sCountSQL: String;
:   iDept_first: Integer;
:   iDept_second: Integer;
:   iDept_third: Integer;
:   iDept_for: Integer;
:   SavePath: String;
:   Loop: Integer;
: begin
:    iDept_first:= 0;
:    Loop:=0;
:    iDept_second:= 0;
:    iDept_third:= 0;
:     FileAttrs := 0 + faAnyFile;
:
:    AdoCon.Open('MFGOVTEST','MFGOVTEST');
:    ShowMessage('연결성공');
:
:    if FindFirst(Path + FileFilter, FileAttrs, sr) = 0 then
:     ShowMessage(Path);
:    begin
:     repeat
:
:       inc(iDept_first);
:       if (sr.name <> '.') and ( sr.Name <> '..') then
:       begin
:         if(sr.Attr and faDirectory ) = faDirectory then
:         begin
:           sCountSQL:= '';
:           sCountSQL:=sCountSQL +'insert into countpage_tbl values(';
:           sCountSQL:=sCountSQL +''''+inttostr(iDept_first)  + ' '',''' + inttostr(iDept_second);
:           sCountSQL:=sCountSQL +''','''+inttostr(0)+ ' '','''+inttostr(0)+' '','' '+ Path + ' '',';
:           sCountSQL:=sCountSQL +''' '  +sr.Name                + ' '',''' + 'D'  + ' '',';
:           sCountSQL:=sCountSQL +inttostr(0)+')';
:
:           AdoQuery.SQL.Add(sCountSQL);
:           AdoQuery.ExecSQL;
:           AdoQuery.SQL.Clear;
:           AdoQuery.Close;
:
:           SavePath:=Path;
:           Path:=Path+sr.Name+'\';
:           svSearch:=sr;
:           FindFirst(Path+FileFilter,FileAttrs,sr);
:
:           repeat
:             if(sr.Name <> '.') and ( sr.Name <> '..') then
:             begin
:                if(sr.Attr and faDirectory ) = faDirectory then begin
:                inc(iDept_third);
:                sCountSQL:= '';
:                sCountSQL:=sCountSQL +'insert into countpage_tbl values(';
:                sCountSQL:=sCountSQL +''''+inttostr(iDept_first)   + ' '',''' + inttostr(iDept_second);
:                sCountSQL:=sCountSQL +''','''+inttostr(iDept_third)+ ' '',''' +inttostr(0)+' '','' ' + Path + ' '',';
:                sCountSQL:=sCountSQL +''' '  +sr.Name                + ' '',''' + 'D'  + ' '',';
:                sCountSQL:=sCountSQL +inttostr(0)+')';
:
:                AdoQuery.SQL.Add(sCountSQL);
:                AdoQuery.ExecSQL;
:                AdoQuery.SQL.Clear;
:                AdoQuery.Close;
:
:                end else
:                inc(iDept_for);
:                inc(Loop);
:                sCountSQL:= '';
:                sCountSQL:=sCountSQL +'insert into countpage_tbl values(';
:                sCountSQL:=sCountSQL +''''+inttostr(iDept_first)   + ' '',''' + inttostr(iDept_second);
:                sCountSQL:=sCountSQL +''','''+inttostr(iDept_third)+ ' '',''' + inttostr(iDept_for)+ ' '','' '+Path + ' '',';
:                sCountSQL:=sCountSQL +''' '  +sr.Name                + ' '',''' + 'F'  + ' '',';
:                sCountSQL:=sCountSQL +inttostr(0)+')';
:
:                AdoQuery.SQL.Add(sCountSQL);
:                AdoQuery.ExecSQL;
:                AdoQuery.SQL.Clear;
:                AdoQuery.Close;
:                end;
:
:           until(FindNext(sr) <> 0);
:           FindClose(sr);
:           Path:=SavePath;
:           ShowMessage(sr.Name);
:           FindFirst(Path+FileFilter,FileAttrs,sr);
:           FindNext(sr);
:
:         end else
:
:         end;
:     until(FindNext(sr)<>0);
:     FindClose(sr);
:    end;
: end;

+ -

관련 글 리스트
10302 [초보] 특정 폴더를 선택해서 하나의 그 안의 폴더와 각 폴더의 파일 갯수에 대해 raincode 1080 2005/10/23
10309     Re:[초보] 특정 폴더를 선택해서 하나의 그 안의 폴더와 각 폴더의 파일 갯수에 대해 civilian,안영제 1544 2005/10/24
10310         [초보] 특정 폴더를 선택해서 하나의 그 안의 폴더와 각 폴더의 파일 갯수에 대해 raincode 1080 2005/10/24
10311             Re:[초보] 특정 폴더를 선택해서 하나의 그 안의 폴더와 각 폴더의 파일 갯수에 대해 civilian,안영제 1307 2005/10/24
10312                 다른 사람이 보기에 복잡해질 수 있을꺼 같아서요 raincode 1132 2005/10/25
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.