Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Gettig file size from given url

$
0
0

Hello.

I need to know size of file from a given url.

In fact I want to get url of a file(anywhere on the internet) and then get size of it.

I tried with this code but I takes long time to get size of large files, is there any better way?

publicasyncTask<IActionResult>Test()
{
longfileSize = 0;
varclient = new HttpClient();
varresponse = await client.GetAsync("http://dl5.downloadha.com/hosein/NarmAfzaar/December2017/Notepad.Plus.Plus.v7.5.2.Installer.x86_www.Downloadha.com_.zip");
fileSize = response.Content.ReadAsStreamAsync().Result.Length;
return Content(fileSize.ToString());
}

Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>