C Copy File Function
從位置 pathFrom 拷貝至 pathTo
BOOL CopyFile(const char *pathfrom, const char *pathto)
{
FILE *fpi = NULL, *fpo = NULL;
int nByteRead = 0;
char szBuffer[MAX_PATH];
BOOL bRet = FALSE;
if( (fpi = fopen( pathfrom, "rb" )) != NULL ) {
if( (fpo = fopen( pathto, "wb" )) != NULL ) {
while( (nByteRead = fread(szBuffer, sizeof(char), MAX_PATH, fpi))> 0 )
fwrite(szBuffer, sizeof(char), nByteRead, fpo);
}
else
goto err_out;
}
else
goto err_out;
bRet = TRUE;
err_out:
if(fpi)
fclose(fpi);
if(fpo)
fclose(fpo);
return bRet;
}