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