Click here to Skip to main content
15,885,665 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
anyone can help me how to calculate the size of file to be downloaded in one second by c # not she (I need code) !!!thank
Posted

Hi
try this code .
C#
// Get file size
long size = fi.Length;
Console.WriteLine("File Size in Bytes: {0}", size);
 
Share this answer
 
Comments
Joezer BH 5-Feb-13 7:45am    
This will take less than a second ;)
vbtoan 5-Feb-13 22:44pm    
helo your solusion . long side = "fi".Length
I did not quite understand the use fi.Length you can specify more than one bit is not
Console.Title = "A simple speedtest app";

// the URL to download a file from
Uri URL = new Uri("http://vodcdn.megatv.vn/vod/ducuong/Skyfall.2012.HD.flv");
WebClient wc = new WebClient();

Console.WriteLine("Welcome to this simple speedtest,\nwhich will test your download rate.");
Console.WriteLine("Press any key to begin.");
Console.ReadKey();

Console.WriteLine("\nDownloading file: ...");
Console.WriteLine("From http://vodcdn.megatv.vn/vod/ducuong/Skyfall.2012.HD.flv");
Console.WriteLine("Note: This file will automatically be deleted after the test.");

wc.DownloadFile(URL, @"string url = HttpContext.Current.Request.Url.AbsoluteUri;");
I use this code to download from the net.I want to measure the size of file to be downloaded in 1 second and display it you can help me
Use HttpPostedFile.ContentLength Property[^] to get the file size of the uploaded file.
So say if your FileUpload control name is Fileupload1, then you can get the size using:
C#
FileUpload1.PostedFile.ContentLength


Hope this helps!
 
Share this answer
 
Comments
vbtoan 5-Feb-13 22:44pm    
Console.Title = "A simple speedtest app";

// the URL to download a file from
Uri URL = new Uri("http://vodcdn.megatv.vn/vod/ducuong/Skyfall.2012.HD.flv");
WebClient wc = new WebClient();

Console.WriteLine("Welcome to this simple speedtest,\nwhich will test your download rate.");
Console.WriteLine("Press any key to begin.");
Console.ReadKey();

Console.WriteLine("\nDownloading file: ...");
Console.WriteLine("From http://vodcdn.megatv.vn/vod/ducuong/Skyfall.2012.HD.flv");
Console.WriteLine("Note: This file will automatically be deleted after the test.");

wc.DownloadFile(URL, @"string url = HttpContext.Current.Request.Url.AbsoluteUri;");
I use this code to download from the net.I want to measure the size of file to be downloaded in 1 second and display it you can help me
Ankur\m/ 6-Feb-13 0:26am    
So it's a windows application and not web application. You wrongly tagged ASP.NET in your question.
Anyways, what is wc in your code?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900