public void DownloadClientJar(GameVersion MC) { bool download = false; long filesize; string fileSHA; string localFilePath = VersionDir + @"\" + MC.Id + @"\" + MC.Id + ".jar"; try { if (File.Exists(localFilePath)) { // check filesize filesize = new FileInfo(localFilePath).Length; if (MC.Downloads.Client.Size != filesize) { File.Delete(localFilePath); download = true; } // check SHA fileSHA = dhelper.ComputeHashSHA(localFilePath); if (!MC.Downloads.Client.Sha1.Equals(fileSHA)) { File.Delete(localFilePath); download = true; } } else { download = true; } // download jar if (download == true) { dhelper.DownloadFileTo(MC.Downloads.Client.Url, localFilePath); } // post download check // check filesize filesize = new FileInfo(localFilePath).Length; if (MC.Downloads.Client.Size != filesize) { throw new Exception("Error downloading file: " + MC.Id + ".jar (filesize mismatch)"); } // check SHA fileSHA = dhelper.ComputeHashSHA(localFilePath); if (!MC.Downloads.Client.Sha1.Equals(fileSHA)) { throw new Exception("Error downloading file: " + MC.Id + ".jar (SHA1 mismatch)"); } } catch (Exception ex) { throw ex; } }