Solved

Mapping progress of CopyFile to a Progress Control

Posted on 2004-10-27
543 Views
Last Modified: 2013-11-20
An MFC Dialog button in my installation code starts a copy of some large files via CopyFile() and I'd like to show the progress of the copy in a Progress bar.  Does CopyFile() or the system provide a variable I can map to the Progress Control?

Thanks for any help.
Steve
0
Question by:steva
    4 Comments
     
    LVL 55

    Assisted Solution

    by:Jaime Olivares
    0
     
    LVL 86

    Assisted Solution

    by:jkr
    Or, use 'SHFileOperation()' instead, it comes with its own progress:

    void CopyFileWithProgress ( char* pszDst, char* pszSrc) {

    SHFILEOPSTRUCT sfo;

    ZeroMemory ( &sfo, sizeof ( sfo));

    sfo.pFrom = pszSrc;
    sfo.fTo = pszDst;
    sfo.wFunc = FO_COPY;
    sfo.fFlags = FOF_SIMPLEPROGRESS;
    sfo.lpszProgressTitle = "Copying your file...";

    SHFileOperation ( &sfo);
    }

    You can even do a wildcard copy (e.g. "*.cpp") with that.
    0
     
    LVL 6

    Accepted Solution

    by:
    look at the progress bars section at this ink

    http://rossm.net/Electronics/Computers/Software/C++/MFC.htm
    0
     

    Author Comment

    by:steva
    I tried using the SHFileOperation() routine but found it flakey. It wouldn't recognize the source file on the floppy if I specified a label in sfo.lpszProgressTitle, and sometimes hit an access error during the copy.  CopyFile(), on the other hand, works everytime with no problems.  I just don't trust SHFileOperation() enough to use it.

    All three comments were great, though,  and helped me through this so I spit the points.

    Thanks for your help.

    Steve
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Suggested Solutions

    Title # Comments Views Activity
    Expand macro to include alternate header placement and naming 5 51
    lucky13 challenge 11 77
    Window placement 17 45
    MaxSpan challenge 9 34
    Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
    Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    931 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now