Revert "Converted items that could be in a using statement"

This reverts commit 3372052131.
This commit is contained in:
Zesty Fernandez 2022-07-14 09:01:03 -07:00
parent 5de52b2b59
commit 21940cf211

View file

@ -4,7 +4,6 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Threading.Tasks;
namespace UWUVCI_AIO_WPF.Classes namespace UWUVCI_AIO_WPF.Classes
{ {
@ -64,22 +63,26 @@ namespace UWUVCI_AIO_WPF.Classes
public static bool DoesToolsFolderExist() public static bool DoesToolsFolderExist()
{ {
return Directory.Exists(FolderName); if (Directory.Exists(FolderName))
{
return true;
}
return false;
} }
public static async Task<bool> IsToolRight(string name) public static bool IsToolRight(string name)
{ {
bool ret = false; bool ret = false;
using (var client = new WebClient()) WebClient client = new WebClient();
client.DownloadFile(backupulr + name + ".md5", name + ".md5");
StreamReader sr = new StreamReader(name + ".md5");
var md5 = sr.ReadLine();
if(CalculateMD5(name) == md5)
{ {
await client.DownloadFile(backupulr + name + ".md5", name + ".md5"); ret = true;
using (var sr = new StreamReader(name + ".md5"))
{
var md5 = sr.ReadLine();
ret = CalculateMD5(name) == md5;
}
File.Delete(name + ".md5");
} }
sr.Close();
File.Delete(name + ".md5");
return ret; return ret;
} }
static string CalculateMD5(string filename) static string CalculateMD5(string filename)
@ -89,6 +92,7 @@ namespace UWUVCI_AIO_WPF.Classes
using (var stream = File.OpenRead(filename)) using (var stream = File.OpenRead(filename))
{ {
string ret = BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "").ToLower(); string ret = BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "").ToLower();
stream.Close();
return ret; return ret;
} }
} }