일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- winsock
- SDK
- 초보
- 설치
- 파라미터
- 파이어버드
- vb
- 소니
- 시리얼 통신
- 예제
- 델파이
- c#
- PostgreSQL
- MFC
- Delphi
- WIN32 SDK
- Visual Studio 2005
- Visual Basic
- 입문
- MySQL
- 데이터베이스
- SQL
- VB.NET
- xml
- dll
- 인스톨
- 셋업
- 기초
- Firebird
- 문자열
- 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;