No need to reinvent the wheel my friend, just check out my opensource git
And to compare files for updating I use the following
Code:
protected void compareFiles()
{
guiInstance.UpdateStatus(0, "Checking client files...");
GUI.Instance.UpdateProgressMaximum(0, FileList.Count);
for (; currentIndex < FileList.Count; ++currentIndex)
{
guiInstance.UpdateProgressValue(0, currentIndex);
Structures.IndexEntry file = FileList[currentIndex];
bool download = false;
guiInstance.UpdateStatus(1, string.Format("Checking file: {0}", file.FileName));
if (file.IsLegacy)
{
if (!File.Exists(resourceFolder + file.FileName) || (Hash.GetSHA512Hash(resourceFolder + file.FileName) != file.FileHash))
{
download = true;
}
}
else
{
DataCore.Structures.IndexEntry fileEntry = Core.GetEntry(ref index, file.FileName);
if (fileEntry != null)
{
string fileHash = Core.GetFileSHA512(settings.GetString("clientdirectory"), Core.GetID(fileEntry.Name), fileEntry.Offset, fileEntry.Length, GetFileExtension(fileEntry.Name));
if (file.FileHash != fileHash)
{
guiInstance.UpdateStatus(1, string.Format("File: {0} is depreciated!", file.FileName));
download = true;
}
}
}
if (download)
{
GUI.Instance.UpdateStatus(1, string.Format("Downloading {0}...", FileList[currentIndex].FileName));
doUpdate();
}
}
}
The above snippet is from my public open source launcher system called "
" which you are more than welcome to use or use as an example.