mirror of
https://github.com/stuff-by-3-random-dudes/UWUVCI-AIO-WPF
synced 2024-11-10 05:34:13 +00:00
Converted items that could be in a using statement
This commit is contained in:
parent
b2d82c670e
commit
3372052131
1 changed files with 11 additions and 15 deletions
|
@ -4,6 +4,7 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UWUVCI_AIO_WPF.Classes
|
||||
{
|
||||
|
@ -63,26 +64,22 @@ namespace UWUVCI_AIO_WPF.Classes
|
|||
|
||||
public static bool DoesToolsFolderExist()
|
||||
{
|
||||
if (Directory.Exists(FolderName))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return Directory.Exists(FolderName);
|
||||
}
|
||||
|
||||
public static bool IsToolRight(string name)
|
||||
public static async Task<bool> IsToolRight(string name)
|
||||
{
|
||||
bool ret = false;
|
||||
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)
|
||||
using (var client = new WebClient())
|
||||
{
|
||||
ret = true;
|
||||
await client.DownloadFile(backupulr + name + ".md5", name + ".md5");
|
||||
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;
|
||||
}
|
||||
static string CalculateMD5(string filename)
|
||||
|
@ -92,7 +89,6 @@ namespace UWUVCI_AIO_WPF.Classes
|
|||
using (var stream = File.OpenRead(filename))
|
||||
{
|
||||
string ret = BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "").ToLower();
|
||||
stream.Close();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue