{ ----------------------------------- FileListを使うユニット 2007/07/22(日) 00:04 ・作成 //----------------------------------- } unit FileListUnit; interface uses SysUtils, //DeleteFile Classes, //StringList FileList; procedure DeleteFileInFolder(FolderPath: String); implementation // {------------------------------- // フォルダの中身のファイルとフォルダを全て削除する // 指定フォルダは削除しない。 備考: 履歴: 2007/07/22(日) 00:00 //--▼----------------------▽--} procedure DeleteFileInFolder(FolderPath: String); var FileList: TFileList; OutputList: TStringList; i: Integer; begin if not DirectoryExists(FolderPath) then Exit; FileList := TFileList.Create(nil); try OutputList := TStringList.Create; try FileList.DestStrings := OutputList; FileList.FileListType := flNormal; FileList.Directory := FolderPath; FileList.SubFolderList; for i := OutputList.Count - 1 downto 0 do begin DeleteFile(PChar(OutputList[i])); end; OutputList.Clear; FileList.FileListType := flFolder; FileList.SubFolderList; for i := OutputList.Count - 1 downto 0 do begin RemoveDir(OutputList[i]); end; finally OutputList.Free; end; finally FileList.Free; end; end; //--△----------------------▲-- end.