• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 252
  • Last Modified:

Better function to download file through http

I already had a function to download file from http server.
My question is, is this function (GetFile()) good enough or there are another functions that work better (in speed)?
If there are better function, I need it.

for information, my program will download about 1000 files (size: 5 kilobytes, each file)

bool CMyProject::GetFile(const char *url, const char *filename)
     #define HTTPBUFLEN    512 // Size of HTTP Buffer...
     char httpbuff[HTTPBUFLEN];
     TCHAR   szCause[255];
          CInternetSession mysession;
          CStdioFile *remotefile = mysession.OpenURL(url,1,INTERNET_FLAG_TRANSFER_BINARY|INTERNET_FLAG_RELOAD);
          CFile myfile(filename, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
            int numbytes;
              while (numbytes = remotefile->Read(httpbuff, HTTPBUFLEN))
                     myfile.Write(httpbuff, numbytes);
              return false;
     return true;
1 Solution
What about

URLDownloadToFile ( NULL, "http://www.experts-exchange.com/thefile.zip", "c:\\somewhere\\thefile.zip", 0, NULL);


AndyAinscowFreelance programmer / ConsultantCommented:
Speed - the slowest bit in this procedure is likely to be your internet connection.  Would another routine actually give you any improvement?
nk2003Author Commented:
Thanks jkr, URLDownloadToFile() is faster than my GetFile() function.
But I still don't know what's bad with my function......  Do you know why?

And one more question, how to input/set the proxy server?
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