Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 575
  • Last Modified:

Mapping progress of CopyFile to a Progress Control

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
steva
Asked:
steva
3 Solutions
 
Jaime OlivaresSoftware ArchitectCommented:
0
 
jkrCommented:
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
 
Amritpal SinghCommented:
look at the progress bars section at this ink

http://rossm.net/Electronics/Computers/Software/C++/MFC.htm
0
 
stevaAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now