[Feature] Fix warning SYSLIB0014 - Replace WebClient with HttpClient (#313), version 1.2.3.8

This commit is contained in:
Markus Hofknecht 2022-02-05 11:58:19 +01:00
parent 2c4e9c656c
commit 4c927a4225
2 changed files with 18 additions and 7 deletions

View file

@ -63,8 +63,6 @@ namespace SystemTrayMenu.Helper
private static void CreateShortcut(string url, string pathToStoreFile)
{
string pathToStoreIcons = Path.Combine(pathToStoreFile, "ico");
using WebClient client = new();
if (!Directory.Exists(pathToStoreIcons))
{
Directory.CreateDirectory(pathToStoreIcons);
@ -74,9 +72,22 @@ namespace SystemTrayMenu.Helper
string hostname = uri.Host.ToString();
string pathIconPng = Path.Combine(pathToStoreIcons, $"{hostname}.png");
client.DownloadFile(
@"http://www.google.com/s2/favicons?sz=32&domain=" + url,
pathIconPng);
string urlGoogleIconDownload = @"http://www.google.com/s2/favicons?sz=32&domain=" + url;
HttpClient client = new HttpClient();
using (HttpResponseMessage response = client.GetAsync(urlGoogleIconDownload).Result)
{
using (HttpContent content = response.Content)
{
Stream stream = content.ReadAsStreamAsync().Result;
using (var fileStream = File.Create(pathIconPng))
{
stream.Seek(0, SeekOrigin.Begin);
stream.CopyTo(fileStream);
}
}
}
string pathIcon = Path.Combine(pathToStoreIcons, $"{hostname}.ico");
ImagingHelper.ConvertToIcon(pathIconPng, pathIcon, 32);
File.Delete(pathIconPng);

View file

@ -39,5 +39,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.3.7")]
[assembly: AssemblyFileVersion("1.2.3.7")]
[assembly: AssemblyVersion("1.2.3.8")]
[assembly: AssemblyFileVersion("1.2.3.8")]