|
-
April 12th, 1999, 01:35 AM
#1
Downloading file using http
I wrote the code below to download a zip file from a web site using http. However when I try it out, it seems that the zip file would be slightly larger than the original file by a few hundred bytes. What am I doing wrong? I kinda suspect that it is due to fwrite(). Or could anyone suggest a better method? Thanks.
int iNumberOfBytesRead;
void *vBytesReadFromFile;
CInternetSession internetSession;
CHttpFile* httpFile = (CHttpFile*)internetSession.OpenURL(url);
vBytesReadFromFile = malloc(sizeof(char) * 4096);
while (1)
{
iNumberOfBytesRead = httpFile->Read(vBytesReadFromFile, 4096);
fwrite(vBytesReadFromFile, iNumberOfBytesRead, 1, fOutput);
if (iNumberOfBytesRead != 4096)
break;
}
httpFile->Close();
fclose(fOutput);
-
May 21st, 1999, 04:32 AM
#2
Re: Downloading file using http
I've made it with a CFile and CFile::Write instead of fwrite and i do not have the problem you described.
There is another little bug with html files when the connexion is very slow : sometimes, the files are incomplete ( i do not see that with zip files or images...)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|