mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-05-15 09:52:37 +12:00
[Feature] Fix warning SYSLIB0014 - Replace WebClient with HttpClient (#313), version 1.2.3.8
This commit is contained in:
parent
2c4e9c656c
commit
4c927a4225
|
@ -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);
|
||||
|
|
|
@ -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")]
|
||||
|
|
Loading…
Reference in a new issue