Home > ASP.NET > Get File size information before you download

Get File size information before you download


Hello,

I was surfing on ASP.NET and found some interesting code snippet for getting file size from the Internet (HTTP) before download get started.

So you can get to know the size of file before you download your file

here is the simple code.

string completeUrl =
TypeYourDownloadbleURL“;
WebClient obj = new WebClient();
Stream s = obj.OpenRead(completeUrl);
Response.Write(obj.ResponseHeaders[“Content-Length”].ToString());
s.Close();
obj = null;

Categories: ASP.NET Tags:
  1. February 17, 2011 at 8:54 AM

    i love it

  2. Mihir Soni
    May 22, 2011 at 7:07 PM

    Thank you

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: