delphi4arab منتديات دلفي للعرب

نسخة كاملة : كيف تم عملية مسح جميع الملفات اللتي تحمل لاحقة معينة
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
السلام عليكم

عندي مجلد فيه مجموعة ملفات لها لواحق مختلفة 
يعني 
html php doc
اريد انا امسح جميع الملفات اللتي لها لاحقة .html من المجلد
وعليكم السلام
PHP كود :
procedure DeleteFilesWithWildCard(Dir, Prefix, Suffix: String);
var
 
 SRec: TSearchRec;
begin
  
{ Check the passed parameter, make sure it ends in a backslash }
 
 if Length(Dir) = 0 then
    Exit
;
 
 if Dir[Length(Dir)] <> '\' then
    AppendStr(Dir, '
\');
  if FindFirst(Dir + Prefix + '
*.' + Suffix, faAnyfile, SRec) = 0 then
  try
    { We must call FindClose after the FindFirst succeeded, otherwise
    the program looses a system handle. So use a try finally block. }
    repeat
      { We have a hit. Check if it is a directory }
      if (faDirectory and SRec.Attr) = 0 then
      begin
        { It is a file, try to delete it. This may fail if the file
        has the read-only attribute. If it does we show a message but
        continue with other files if the user does not abort. }
        if not SysUtils.DeleteFile(Dir + SRec.Name) then
        begin
          if MessageDlg(
            '
Cannot delete ' + SRec.Name +
            '
, the file may be read-only. Do you want to abort the ' +
            '
operation?',
            mtError,
            [mbYes, mbNo, mbCancel],
            0
          ) <> mrNo then
          SysUtils.Abort;
        end;
      end;
    { Done with this hit, search for the next one. }
    until
      FindNext(SRec) <> 0;
  finally
    FindClose(SRec);
  end;
end;

// Example: how to use DeleteFilesWithWildCard

procedure TForm1.Button1Click(Sender: TObject);
begin
  DeleteFilesWithWildCard('
C:\Users\Admin\Desktop\New folder', '', 'html');
end; 
المصدر
هذا هو المطلوب اخي بارك الله فيك
استخدم هذا الاجراء
PHP كود :
procedure DeleteFiles(Path: string; Name: string);
var 
srec: TSearchRec;
begin
Path
:=Path+'\';
if FindFirst(Path+Name, faAnyFile, srec)=0 then
begin
DeleteFile(Path+srec.Name);
while FindNext(srec)=0 do
DeleteFile(Path+srec.Name);
end;
FindCLose(srec);
end;
وهذا هو الاستدعاء

DeleteFiles('
C:\Users\GENNARO\Desktop\New folder', '*.exe');