/// <summary> /// The big boi, the download process /// </summary> /// <param name="_QuasarDownload">Quasar Download item to process</param> /// <returns></returns> public async Task <bool> DownloadArchiveAsync(QuasarDownload _QuasarDownload) { //Getting info from Quasar URL var DownloadURL = new Uri(_QuasarDownload.DownloadURL); var DestinationFolderPath = DefaultDirectoryPath + "\\Library\\Downloads\\"; var DestinationFilePath = DestinationFolderPath + ModListItemView.LibraryItem.Guid + "." + _QuasarDownload.ModArchiveFormat; FileOperation.CheckCreate(DestinationFolderPath); //Setting up Progress actions void DownloadProgressChangedEvent(object s, DownloadProgressChangedEventArgs e) { //Changing ProgressBar value ModListItemView.ProgressBarValue = e.ProgressPercentage; //ModListItem.Progress.Dispatcher.BeginInvoke((Action)(() => { ModListItem.ProgressBarValue = e.ProgressPercentage; })); //Making a proper string to display var downloadProgress = string.Format("{0} MB / {1} MB", (e.BytesReceived / 1024d / 1024d).ToString("0.00"), (e.TotalBytesToReceive / 1024d / 1024d).ToString("0.00")); //Displaying value ModListItemView.ModStatusTextValue = downloadProgress; //ModListItem.ModStatusTextLabel.Dispatcher.BeginInvoke((Action)(() => { ModListItem.ModStatusTextValue = downloadProgress; })); } //File Download using (WebClient webClient = new WebClient()) { webClient.DownloadProgressChanged += DownloadProgressChangedEvent; await webClient.DownloadFileTaskAsync(DownloadURL, DestinationFilePath); } return(true); }
/// <summary> /// Verifies needed folders for execution /// </summary> public static void CreateBaseFolders() { //Setting Paths String InstallationPath = Properties.Settings.Default.DefaultDir; String AppPath = Properties.Settings.Default.AppPath; String LibraryPath = "\\Library\\"; String ModsPath = "\\Library\\Mods\\"; String DownloadsPath = "\\Library\\Downloads\\"; String ScreenshotPath = "\\Library\\Screenshots\\"; String ResourcePath = "\\Resources\\"; FileOperation.CheckCreate(InstallationPath); FileOperation.CheckCreate(InstallationPath + LibraryPath); FileOperation.CheckCreate(InstallationPath + ModsPath); FileOperation.CheckCreate(InstallationPath + DownloadsPath); FileOperation.CheckCreate(InstallationPath + ScreenshotPath); FileOperation.CheckCopyFolder(AppPath + ResourcePath, InstallationPath + ResourcePath); }