.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Remoting >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Get Notification of file size before you start your download

Posted By:Mihir Soni       Posted Date: February 09, 2011    Points: 15    Category: Remoting    URL: http://www.dotnetspark.com  

Hello, Below is the code through which you will be able to get size of downloadable file before the actual downloads start.
 

Hello,

Below is code through which you'll be able to get size of the downloadable file

string completeUrl =
"TypeYourDownloadbleURL";//Please write the exact URL of file
WebClient obj = new WebClient(); //New object of WebClient
Stream s = obj.OpenRead(completeUrl); 
Response.Write(obj.ResponseHeaders["Content-Length"].ToString());//Get the size
s.Close();
obj = null;
I hope that helps you.

Thank you.

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend