public bool downloadParams(String file, Types.DownloadFileType downloadType) { String webLink = "https://snowgem.org/downloads/"; String fileLink = webLink + file; String appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); String fileLoc = appdata + "\\SnowgemParams\\" + file; Int64 length = 0; WebClient wc = new WebClient(); Stream response = null; Int64 bytes_total = 0; if (downloadType == Types.DownloadFileType.PROVING) { wc.DownloadProgressChanged += proving_DownloadProgressChanged; wc.DownloadFileCompleted += proving_DownloadFileCompleted; } else { wc.DownloadProgressChanged += verifying_DownloadProgressChanged; wc.DownloadFileCompleted += verifying_DownloadFileCompleted; } wc.DownloadFileAsync(new System.Uri(fileLink), appdata + "\\SnowgemParams\\" + file, true); return(true); }
public bool downloadParams(String file, Types.DownloadFileType downloadType) { bool shouldDownload = false; String webLink = "https://files.zeromachine.io/"; String fileLink = webLink + file; String appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); String fileLoc = appdata + "\\ZcashParams\\" + file; Int64 length = 0; WebClient wc = new WebClient(); Stream response = null; Int64 bytes_total = 0; try { response = wc.OpenRead(new System.Uri(fileLink)); bytes_total = Convert.ToInt64(wc.ResponseHeaders["Content-Length"]); response.Close(); length = new System.IO.FileInfo(fileLoc).Length; } catch { } if (bytes_total != length) { shouldDownload = true; } if (shouldDownload) { if (downloadType == Types.DownloadFileType.PROVING) { wc.DownloadProgressChanged += proving_DownloadProgressChanged; wc.DownloadFileCompleted += proving_DownloadFileCompleted; } else if (downloadType == Types.DownloadFileType.VERIFYING) { wc.DownloadProgressChanged += verifying_DownloadProgressChanged; wc.DownloadFileCompleted += verifying_DownloadFileCompleted; } else if (downloadType == Types.DownloadFileType.GROTH) { wc.DownloadProgressChanged += groth_DownloadProgressChanged; wc.DownloadFileCompleted += groth_DownloadFileCompleted; } else if (downloadType == Types.DownloadFileType.SPEND) { wc.DownloadProgressChanged += spend_DownloadProgressChanged; wc.DownloadFileCompleted += spend_DownloadFileCompleted; } else if (downloadType == Types.DownloadFileType.OUTPUT) { wc.DownloadProgressChanged += output_DownloadProgressChanged; wc.DownloadFileCompleted += output_DownloadFileCompleted; } wc.DownloadFileAsync(new System.Uri(fileLink), appdata + "\\ZcashParams\\" + file, true); } return(shouldDownload); }
public bool downloadParams(String file, Types.DownloadFileType downloadType) { bool shouldDownload = false; String webLink = "https://snowgem.org/downloads/"; String fileLink = webLink + file; String appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); String fileLoc = appdata + "\\SnowgemParams\\" + file; Int64 length = 0; WebClient wc = new WebClient(); Stream response = null; Int64 bytes_total = 0; try { response = wc.OpenRead(new System.Uri(fileLink)); bytes_total = Convert.ToInt64(wc.ResponseHeaders["Content-Length"]); response.Close(); length = new System.IO.FileInfo(fileLoc).Length; } catch (Exception ex) { //MessageBox.Show(ex.Message); } if (bytes_total != length) { shouldDownload = true; } if (shouldDownload) { if (downloadType == Types.DownloadFileType.PROVING) { wc.DownloadProgressChanged += proving_DownloadProgressChanged; wc.DownloadFileCompleted += proving_DownloadFileCompleted; } else { wc.DownloadProgressChanged += verifying_DownloadProgressChanged; wc.DownloadFileCompleted += verifying_DownloadFileCompleted; } wc.DownloadFileAsync(new System.Uri(fileLink), appdata + "\\SnowgemParams\\" + file, true); } return(shouldDownload); }