関連記事
- Delphi5をWindows7 64ビット環境に突っ込んでみた 【2011年01月15日(土)】
- NET FRAMEWORKのソケット通信 【2010年11月30日(火)】
- 不具合じゃ不具合じゃ! 【2008年05月28日(水)】
- IXMLDOMNodeの検索PGサンプル 【2008年05月22日(木)】
- IXMLDOMDocumentのインスタンス 【2008年01月30日(水)】
ファイルリストの取得の必要性が出てきたもんで,書き倒してみました
-
ワイルドカード対応
深い階層のフォルダ内検索と指定フォルダのみ(深階層は無視)の検索
ここにも書いておきます
御自由にドゾー(バグってたら,連絡ください(汗)
手続き名
Get_FileList(sPath:String; slFList:TStringList; wildStr : string = ”; dirFl : Bool = false);
引数
-
sPath:String
検索を開始するフォルダ名
slFList:TStringList
検索結果を格納するTStringListクラスのインスタンス
wildStr : string = ”
ワイルドカード “*.*”とか,”a*.txt”とか,OK!省略可能.省略時は “*.*”と同等
dirFl : Bool = false
深階層のフォルダを検索するかのフラグ(true:深階層を追っかける, false:追っかけない)
省略可能.省略時はfalse
//***********************************************
//ファイルリストを取得(主処理@再帰を利用)
//
//***********************************************
procedure Get_FileListCore(sPath:String; slFList:TStringList; wildStr : string; dirFl : Bool);
var
tmpFPath : String;
SRec: TSearchRec;
begin
if sPath[length(sPath)] <> '\' then
begin
sPath := sPath + '\';
end;
if wildStr = '' then
begin
tmpFPath := sPath + '*.*';
end
else
begin
tmpFPath := sPath + wildStr;
end;
if FindFirst(tmpFPath, faAnyFile or faDirectory, SRec) = 0 then
begin
repeat
if not ((SRec.Name = '.') or (SRec.Name = '..')) then
begin
if (SRec.Attr and faDirectory) = 0 then
begin
slFList.add(sPath + SRec.Name);
end
else
begin
if dirFl = true then
begin
Get_FileListCore(sPath + SRec.Name + '\', slFList, wildStr, dirFl);
end;
end;
end;
until FindNext(SRec) <> 0;
FindClose(SRec);
end;
end;
//***********************************************
//ファイルリストを取得
//
//***********************************************
procedure Get_FileList(sPath:String; slFList:TStringList; wildStr : string = ''; dirFl : Bool = false);
begin
slFList.Clear;
Get_FileListCore(sPath, slFList, wildStr, dirFL);
end;

コメント
土砂降りじゃー 春の雨が降りまくってる
今週は天気が悪いっぽい.ようやっと雨が定期的に降りだした
【#花粉症】目が腫れてキターくしゃみも止まらん.いよいよ花粉もピークか?
【#衆議院選挙2026 】自民 316議席獲得 単独で3分の2超 中道は49議席
【#衆議院選挙2026 】自民単独で過半数大きく上回り300議席に達する可能性
【BW55T】UPSが死んだ...ドロドロドロ😭これは人類滅亡間違いなし!なので発注(爆
広島カープの羽月隆太郎容疑者、「ゾンビたばこ」使用の疑いで逮捕