怎样删除相同扩展名的文件??

解决方案 »

  1.   

    使用SHFileOperation API
    在ShellAPI.pas中,很好用的,具体的请看MSDN或网上找
    这是COPY的例子
    var
      ops:tshfileopstruct;
      sb,tb:array[0..255] of char;
      tempstr,swpstr:string;
      source,target:string;
    begin 
    ...
      source:=sourcefolder.Text;
      target:=targetfolder.Text;
      fillchar(sb,sizeof(sb),0);
      fillchar(tb,sizeof(tb),0);
      strpcopy(sb,pchar(source));
      strpcopy(tb,pchar(target));
      with ops do
        begin
          wnd:=handle;
          wfunc:=fo_copy; //改为fo_delete就是Del了
          pfrom:=@sb;
          pto:=@tb;
          fAnyOperationsAborted:=true;
          fflags:={FOF_NOCONFIRMATION or} FOF_NOCONFIRMMKDIR or FOF_MULTIDESTFILES;
          hnamemappings:=nil;
          lpszprogresstitle:=nil;
        end;
      if shfileoperation(ops)=0 then showmessage('Copy Done');