IEnumerator DownloadFile() { Uri request = BuildRequests.BuildDownloadFileRequest( DownloadFileChannel, DownloadFileID.ToString(), DownloadFileName.ToString(), this.PubNubInstance, null ); downloadWWW = new UnityWebRequest(request.OriginalString); #if (ENABLE_PUBNUB_LOGGING) this.PubNubInstance.PNLog.WriteToLog(string.Format("Download URL: {0}", request.OriginalString), PNLoggingMethod.LevelInfo); #endif downloadWWW.method = UnityWebRequest.kHttpVerbGET; var dh = new DownloadHandlerFile(DownloadFileSavePath); dh.removeFileOnAbort = true; downloadWWW.downloadHandler = dh; yield return(downloadWWW.SendWebRequest()); DownloadCallback(CreatePNStatus(downloadWWW)); }
void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { try { string FileName = DownloadFileName.Replace(".zip", ""); OpenCloseWaitScreen(false); sw.Reset(); //if directory exists just delete it if (Directory.Exists(AppCommonPath() + FileName)) { DeleteDirectory(AppCommonPath() + FileName); } //create libvlc directory if (!Directory.Exists(AppCommonPath() + FileName)) { Directory.CreateDirectory(AppCommonPath() + FileName); } ZipFile.ExtractToDirectory(AppCommonPath() + DownloadFileName, AppCommonPath() + @"\" + FileName + @"\"); Application.Current.Dispatcher.Invoke((Action) delegate { // your code MessageBox ps4mes = new MessageBox("Content Downloaded and Added\n\nPlease Restart The Application", "Done", PS4_MessageBoxButton.OK, SoundClass.Sound.Notification); ps4mes.ShowDialog(); }); } catch (Exception ex) { MessageBox ps4mes = new MessageBox("Error Downloading or Extracting custom EMU\n" + ex.Message, "Error", PS4_MessageBoxButton.OK, SoundClass.Sound.Error); ps4mes.ShowDialog(); } }