Skip to content

Commit

Permalink
[Feature] Fix warning SYSLIB0014 - Replace WebClient with HttpClient (#…
Browse files Browse the repository at this point in the history
…313), version 1.2.3.8
  • Loading branch information
Hofknecht committed Feb 5, 2022
1 parent 2c4e9c6 commit 4c927a4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
21 changes: 16 additions & 5 deletions Helpers/DragDropHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ public static void DragDrop(object sender, DragEventArgs e)
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);
Expand All @@ -74,9 +72,22 @@ private static void CreateShortcut(string url, string pathToStoreFile)
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);
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@
// 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")]

0 comments on commit 4c927a4

Please sign in to comment.