関連記事
- 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;

コメント
【#パイナップル】パイナップル様をベランダへ移動させたべ
明日は天気が悪くなるの.花芽が大きくなるような降雨かの?
宮崎交通 路線バス 4月から大幅減便 運転士不足で(26/3/14)
JR大阪駅近くの工事現場 下水道の管が地上部分にせり出したか
雷が鳴ってる!今年初の雷キター
【#イラン戦争】イラン最高指導者ハメネイ師が死亡 トランプ大統領 SNSに投稿
土砂降りじゃー 春の雨が降りまくってる
今週は天気が悪いっぽい.ようやっと雨が定期的に降りだした
【#花粉症】目が腫れてキターくしゃみも止まらん.いよいよ花粉もピークか?