private async Task <string> FileLoadAsync(string filePath) { try { string extension = Path.GetExtension(filePath).ToLower(); // If the file is encrypted. if (extension == ".rpgmvo" || extension == ".ogg_" || extension == ".rpgmvm" || extension == ".m4a_" || extension == ".rpgmvw" || extension == ".wav_") { var verifyTask = new Task <bool>(() => CryptographyProvider.VerifyFakeHeader(filePath)); verifyTask.Start(); await verifyTask; if (!verifyTask.Result) { throw new InvalidDataException("An invalid *.rpgmvo(*.ogg_), *.rpgmvm(*.m4a_), *.rpgmvw(*.wav_) file was entered."); } // Restore the file. string tempFilePath = Path.GetTempFileName(); if (extension == ".rpgmvo" || extension == ".ogg_") { var restoreTask = new Task(() => CryptographyProvider.RestoreOggHeader(filePath, tempFilePath)); restoreTask.Start(); await restoreTask; _isUnstable = true; return(tempFilePath); } else { var restoreTask = new Task(() => CryptographyProvider.RestoreHeader(filePath, tempFilePath)); restoreTask.Start(); await restoreTask; return(tempFilePath); } } else { return(filePath); } } catch (Exception ex) { Workspace.Instance.Report.AddReportWithIdentifier($"{ex.Message}\r\n{ex.StackTrace}", ReportType.Warning); return(null); } }