일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 데이터베이스
- 파라미터
- 파이어버드
- 셋업
- SQL
- VB.NET
- Visual Basic
- 문자열
- 초보
- SDK
- MySQL
- MFC
- 기초
- 델파이
- winsock
- xml
- vb
- Firebird
- 설치
- 입문
- Visual Studio 2005
- WIN32 SDK
- dll
- Delphi
- c#
- 예제
- 소니
- 인스톨
- PostgreSQL
- 시리얼 통신
- Today
- Total
프로그래밍 노트
[델파이] 지정한 폴더의 파일 리스트 가져오기(서브 폴더 검색 대응) 본문
// 지정한 폴더의 파일 리스트 가져오기 : 서브 폴더 검색 대응
function FindFiles(const sPath, sMask: string; slFiles: TStringList; bSubDir: boolean): integer;
var
iFindResult: integer;
srSchRec : TSearchRec;
begin
result := 0;
iFindResult := FindFirst(sPath + sMask, faAnyFile - faDirectory, srSchRec);
while iFindResult = 0 do
begin
slFiles.Add(sPath + srSchRec.Name);
iFindResult := FindNext(srSchRec);
end;
FindClose(srSchRec);
if bSubDir then
begin
iFindResult := FindFirst(sPath + '*.*', faDirectory, srSchRec);
while iFindResult = 0 do
begin
if (srSchRec.Name <> '.') and (srSchRec.Name <> '..') then
result := result + FindFiles(sPath + srSchRec.Name + '\', sMask, slFiles, TRUE);
iFindResult := FindNext(srSchRec);
end;
FindClose(srSchRec);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
sl: TStringList;
begin
Button1.Enabled := false;
sl := TStringList.Create;
sl.Clear;
FindFiles('D:\Data\', '*.doc', sl, True);
Listbox1.Items := sl;
sl.Free;
Button1.Enabled := True;
end;