69 lines
1.6 KiB
C#
69 lines
1.6 KiB
C#
|
using ModernWpf.Controls;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.IO;
|
|||
|
using System.Net;
|
|||
|
using System.Security.Cryptography;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Windows.Forms;
|
|||
|
|
|||
|
namespace EZPPClient_Installer
|
|||
|
{
|
|||
|
public class DownloadUtil
|
|||
|
{
|
|||
|
|
|||
|
public static List<string> FilesToDownload(string pathToEZPP)
|
|||
|
{
|
|||
|
bool directoryExists = Directory.Exists(pathToEZPP);
|
|||
|
|
|||
|
List<string> downloadList = new List<string>();
|
|||
|
List<MD5File> md5Files = new List<MD5File>();
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
|
|||
|
using (WebClient wc = new WebClient())
|
|||
|
{
|
|||
|
var data = wc.DownloadString("https://ez-pp.farm/static/client/client.data");
|
|||
|
string[] dataList = data.Split('\n');
|
|||
|
foreach (string datastring in dataList)
|
|||
|
{
|
|||
|
if (string.IsNullOrWhiteSpace(datastring))
|
|||
|
continue;
|
|||
|
|
|||
|
string[] se = datastring.Split('#');
|
|||
|
string md5 = se[0];
|
|||
|
string name = se[1];
|
|||
|
md5Files.Add(new MD5File(name, md5));
|
|||
|
}
|
|||
|
}
|
|||
|
}catch(WebException error)
|
|||
|
{
|
|||
|
new ContentDialog()
|
|||
|
{
|
|||
|
Title = "Oops...",
|
|||
|
Content = "A error occurred while trying to fetch all needed Files.\n" + error.Message,
|
|||
|
PrimaryButtonText = "Okay"
|
|||
|
}.ShowAsync();
|
|||
|
}
|
|||
|
|
|||
|
if (!directoryExists)
|
|||
|
{
|
|||
|
foreach (MD5File md5File in md5Files)
|
|||
|
downloadList.Add(md5File.getName());
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
return downloadList;
|
|||
|
}
|
|||
|
|
|||
|
public async Task<bool> CheckForUpdate()
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|