Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 파이어버드
- Visual Studio 2005
- SDK
- 데이터베이스
- xml
- 인스톨
- 예제
- c#
- 셋업
- 시리얼 통신
- VB.NET
- 설치
- dll
- MFC
- winsock
- 문자열
- vb
- PostgreSQL
- MySQL
- 소니
- 초보
- 파라미터
- 델파이
- Delphi
- SQL
- 입문
- Visual Basic
- Firebird
- WIN32 SDK
- 기초
Archives
- Today
- Total
프로그래밍 노트
[Delphi] SubFolder 안의 File 검색하기 본문
// GetFileList : Sub Folder안의 File까지 검색하는 함수
// slFileList : 반환하는 File List
// sPath : 검색한 Root Folder
// sMask : File 검색 Mask 설정
// 예) '*.txt', '*.exe'
// bSubDir : SubFolder 검색 유무
procedure GetFileList(slFileList: TStringList;
sPath, sMask: string; bSubDir: boolean);
var
i, iFindRst : integer;
SrchRec : TSearchRec;
slFolder : TStringList;
begin
if sPath[length(sPath)] <> '\' then
sPath := sPath + '\';
// 지정 Foldr 안의 지정 Mask의 Full File path 수집
iFindRst := FindFirst(sPath + sMask, faAnyFile - faDirectory, SrchRec);
while iFindRst = 0 do
begin
slFileList.Add(sPath + SrchRec.Name);
iFindRst := FindNext(SrchRec);
end;
FindClose(SrchRec);
// Sub Folder List 수집
slFolder := TStringList.Create;
iFindRst := FindFirst(sPath + '*.*', faAnyFile, SrchRec);
while iFindRst = 0 do begin
if ((SrchRec.Attr and faDirectory) <> 0) and (SrchRec.Name[1] <> '.') then
slFolder.Add(sPath + SrchRec.Name);
iFindRst := FindNext(SrchRec);
end;
FindClose(SrchRec);
// Sub Folder안 File 검색
for i := 0 to slFolder.Count - 1 do
GetFileList(slFileList, slFolder[i], sMask, bSubDir);
slFolder.Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
slFiles : TStringList;
begin
slFiles := TStringList.Create;
GetFileList(slFiles, 'c:\data\', '*.txt', true); //
memo1.Clear;
memo1.Lines := slFiles;
slFiles.Free;
end;
Comments