I'm using .Net 4.5 version for this C# project and successfully Implementing a Download using this Code (taken from zetcode):
Program.cs
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
namespace HttpClientDownloadImage
{
class Program
{
static async Task Main(string[] args)
{
using var httpClient = new HttpClient();
var url = "http://webcode.me/favicon.ico";
byte[] imageBytes = await httpClient.GetByteArrayAsync(url);
string documentsPath = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.Personal);
string localFilename = "favicon.ico";
string localPath = Path.Combine(documentsPath, localFilename);
File.WriteAllBytes(localPath, imageBytes);
}
}
}
1st Problem is : no way to implement percentage 0% until 100% from the async call. From File.WriteAllBytes() how to show the progress out into ant (int/double) variable or something?
2nd Problem is: when I checked on nu package manager, for the Library of System.Net.Http but the versioning is strange. Look at the number shown! It's not matched! 4.3.4 and 4.0.0 What is that?