Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 4-Feb-13 23:10pm
vbtoan287
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi
try this code .
// Get file size
long size = fi.Length;
Console.WriteLine("File Size in Bytes: {0}", size);
  Permalink  
Comments
Edo Tzumer at 5-Feb-13 7:45am
   
This will take less than a second ;)
vbtoan at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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:
FileUpload1.PostedFile.ContentLength
 
Hope this helps!
  Permalink  
Comments
vbtoan at 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/ at 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)

  Print Answers RSS
0 OriginalGriff 275
1 DamithSL 265
2 CPallini 235
3 Maciej Los 185
4 George Jonsson 170
0 OriginalGriff 5,305
1 DamithSL 4,382
2 Maciej Los 3,760
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,901


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 5 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100