Dear Forum, I am trying to write a windows application that copies files from a CD. How do I get the file progress of the installation? I'm using the CopyFile() function and I want a progress control to show progress. How do I get the file progress of the installation? I don't need a lot of code, but a few lines would be nice. Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hmm, one way I can think of doing this that may be actually faster than CopyFile() would be to use malloc() to build like a one meg chunk or something in memory, then fopen() the file, then fread() sequentlially. Each time you incremement progress bar. You can obtain a file's size by using my getFileSize() function. Observe...
// Returns the file size of pszFileName in bytes. -1 on error...
int getFileSize(char *pszFileName)
{
// Variables...
long lFileSize = 0;
FILE *someFile;
// Open the file...
someFile = fopen(pszFileName, "r");
// Check for error...
if(!someFile)
return -1;
// Get file size...
fseek(someFile, 0, SEEK_END);
lFileSize = ftell(someFile);
// Close stream...
fclose(someFile);
// Return file size...
return lFileSize;
}
Good luck =)
Kip
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear Forum, I am trying to write a windows application that copies files from a CD. How do I get the file progress of the installation? I'm using the CopyFile() function and I want a progress control to show progress. How do I get the file progress of the installation? I don't need a lot of code, but a few lines would be nice. Thanks!
Hmm, one way I can think of doing this that may be actually faster than CopyFile() would be to use malloc() to build like a one meg chunk or something in memory, then fopen() the file, then fread() sequentlially. Each time you incremement progress bar. You can obtain a file's size by using my getFileSize() function. Observe...
// Returns the file size of pszFileName in bytes. -1 on error...
int getFileSize(char *pszFileName)
{
// Variables...
long lFileSize = 0;
FILE *someFile;
// Open the file...
someFile = fopen(pszFileName, "r");
// Check for error...
if(!someFile)
return -1;
// Get file size...
fseek(someFile, 0, SEEK_END);
lFileSize = ftell(someFile);
// Close stream...
fclose(someFile);
// Return file size...
return lFileSize;
}
Good luck =)
Kip