関連記事
- 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;
コメント
【大地震】カムチャツカ半島沖合で地震 マグニチュード7.5と推定(25/9/13)
台風一過なのに今日も猛暑予想.秋が来ないぞい
【霧島山】新燃岳が噴火 噴煙高度火口上5500m(25/8/28)
日産「GT-R」生産終了 スポーツカーの開発環境 厳しさ増す
火球か?隕石か?「夜なのに明るく」「カメラが真っ白になるほどの光」九州や西日本各地で目撃あいつぐ 空気の振動も観測
ひょっとして,大規模にやらかしてました?ぎんゆぅ~さん,落ちてた模様(爆