Vinod Paul
Vinod Paul

Reputation: 359

How to get the file size before downloading

I am trying to download a binary file from a http: server. I am using the functions InternetOpenUrl() and then InternetReadFile() to download the file. Is it possible to know the size of the file before downloading?.

Thanks Vinod

Upvotes: 1

Views: 2404

Answers (2)

Some programmer dude
Some programmer dude

Reputation: 409186

You might want to call InternetGetLastResponseInfo after the call to InternetOpenUrl to get the response headers. Those should (most likely) contain the content-length of the file.

Upvotes: 0

Jonathan Potter
Jonathan Potter

Reputation: 37132

You can use HttpQueryInfo() with HTTP_QUERY_CONTENT_LENGTH for this, although the server is not required to send the content length and so you should not rely on this.

Upvotes: 5

Related Questions