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