関連記事
- 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;
コメント
【#緊急非常事態】スマホを紛失した!amazonで買ったカナビラがぶっ壊れてスマホが消えた!
「君たちはどう生きるか」「ゴジラ-1.0」アカデミー賞を受賞
昼から雨だそうな.人が洗車すると..ブツブツ
【訃報】TARAKOさん急死 63歳 「ちびまる子ちゃん」を35年
【#訃報】漫画家 鳥山明さん死去 68歳 「DRAGON BALL」などで人気
たぬきケーキの人気再燃 レトロな魅力、再販する店も
【#株価】日経平均株価 終値で初の4万円台 史上最高値を更新(24/3/4)
睡眠「成人は6時間以上」 新ガイドは日本人の眠りを変えられるか
再起動不要でWindows 11をアップデートする機能、2024年後半に導入か
【#確定申告】さて,税務も終わった件