我要实现从一个文件夹A中的jpg文件全部转移到到文件夹b中。但是A中的文件数目和文件名是未知的。请教各位大虾!怎么实现?是不是在DELPHI中也有文件指针的东东!?我用CHDIR把当前目录改为A,但是不知道怎么办了?因为没有像文件指针的东西!谢谢了!

解决方案 »

  1.   

    老兄呀 你的问题可以转化为目录拷贝 ?are you ok ?文件数目和文件名未知没什么的!!!可以用递归来实现的 !要源代码的话,加我qq16628152
      

  2.   

    FindFirst,FindNext,CopyFile,CopyFileTo,DeleteFile
      

  3.   

    用外部命令调用copy c:\\*.jpg d:\\*.*
      

  4.   

    to  cowboyseu (王胖)  :
       直接转移文件夹
       我帮你做好了~~~
       假设你原来的目录为 c:\tyn1   你现在想备份到 c:\tyn2目录下
    ~~~~~~
    procedure TForm1.Button1Click(Sender: TObject);
    var
     FileOpStruct :TSHFileOpStruct;
     Buf1 :array [0..127] of Char;
     Buf2 :array [0..127] of Char;
     Str1,Str2 :String;
    begin
     Str1 :='c:\tyn1';
     Str2 :='c:\tyn2';
     FillChar(Buf1,SizeOf(Buf1),0);
     FillChar(Buf2,SizeOf(Buf2),0);
     StrPCopy(Buf1,Str1);
     StrPCopy(Buf2,Str2);
     with FileOpStruct do
     begin
       Wnd :=Handle;
       wFunc :=FO_COPY;
       pFrom :=@Buf1;
       pTo :=@Buf2;
       fFlags :=FOF_SIMPLEPROGRESS;
       fAnyOperationsAborted :=False;
       hNameMappings :=nil;
       lpszProgressTitle :='拷贝文件';
     end;
     SHFileOperation(FileOpStruct);
    end;  
      

  5.   

    文件復制,可參考一下.
    procedure TfmTaskSearcher.SearchTask(const sDir, sExtension: String);
    var
      sSearchPath: String;
      sr: TSearchRec;
      NewItem: TListItem;
      iCount: Integer;
      sCaption: String;
    begin
      iCount := 0;
      if Copy(sDir, Length(sDir), 1) <> '\' then
        sSearchPath := sDir + '\'
      else
        sSearchPath := sDir;
      if FindFirst(sSearchPath + '*.'+ sExtension, 0, sr) = 0 then
      begin
        with FileListView do
        begin
          sCaption := sSearchPath + sr.Name;
          if FindCaption(1, sCaption, False, True, True) = nil then
          begin
            NewItem := Items.Add;
            NewItem.Caption := sCaption;
            Inc(iCount);
          end;
          while FindNext(sr) = 0 do
          begin
            sCaption := sSearchPath + sr.Name;
            if FindCaption(1, sCaption, False, True, True) = nil then
            begin
              NewItem := Items.Add;
              NewItem.Caption := sCaption;
              Inc(iCount);
            end;
          end;
        end;
        FindClose(sr);
      end;
      if iCount > 0 then
      begin
        MessageBox(0, Pchar('You have ' + IntToStr(iCount) + ' new tasks!'), 'Information', MB_OK + MB_ICONINFORMATION);
      end;
    end;