Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 399649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:52:00+00:00 2026-05-12T16:52:00+00:00

In my application I need to copy over 1000 small files Here is the

  • 0

In my application I need to copy over 1000 small files

Here is the code I am using but it is VERY SLOW
Is there a better way of doing this ?

procedure Tdatafeeds.RestotreTodaysFiles;
var
  SearchRec: TSearchRec;
  FromFn, ToFn: string;
Begin
    if DirectoryExists(BackupPath1) then
    begin
      try
        if FindFirst(BackupPath1 + '\*.*', (faAnyFile AND NOT(faDirectory)), SearchRec) = 0 then
        begin
          repeat
            FromFn := BackupPath1 + '\' + SearchRec.name;
            ToFn := DatafeedsPath1 + '\' + SearchRec.name;
            CopyFile(Pchar(FromFn), Pchar(ToFn), false);
          until FindNext(SearchRec) <> 0;
        end;
      finally
        FindClose(SearchRec);
      end;
    end;
End;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T16:52:01+00:00Added an answer on May 12, 2026 at 4:52 pm

    Definitely go with SHFileOperation() as suggested above, CopyFile is way too slow for that many files. It looks like you are basically restoring an entire folder so the search function may be unnecessary and slow things down further. Something like this may be of help:

    uses ShellApi;
    
    function CopyDir(const fromDir, toDir: string): Boolean;
    var
      fos: TSHFileOpStruct;
    begin
      ZeroMemory(@fos, SizeOf(fos));
      with fos do
      begin
        wFunc  := FO_COPY;
        fFlags := FOF_FILESONLY;
        pFrom  := PChar(fromDir + #0);
        pTo    := PChar(toDir)
      end;
      Result := (0 = ShFileOperation(fos));
    end;
    

    This function will raise a prompt to overwrite existing files though (maybe it can be tweaked to skip that) but the user can select “All” so it’s a one-click procedure, much faster, has a progress bar and can be canceled if desired.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application I need to analyze. I have the source code here.
I need a application to copy text and images form PowerPoint to Word. I
I need my QT application to create a table and copy this table into
Using C# (vs2005) I need to copy a table from one database to another.
I've been given the task of writing a small application to help migrate over
I'm trying make an WPF application that I could copy/cut and paste files info
I have a web application that receives a simple text file, but I need
I need to encrypt a text string in a .net application using a known
In the java web application need to select the file from server and print
Hi every body i am new in iPhone application development. In my application need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.