diff --git a/AssetStudio.GUI/Studio.cs b/AssetStudio.GUI/Studio.cs index c7d7454f..74e0f9bb 100644 --- a/AssetStudio.GUI/Studio.cs +++ b/AssetStudio.GUI/Studio.cs @@ -525,6 +525,8 @@ public static void ExportAssets(string savePath, List toExportAssets, int toExportCount = toExportAssets.Count; int exportedCount = 0; + string logFilePath = ""; + bool ExportError = false; int i = 0; Progress.Reset(); foreach (var asset in toExportAssets) @@ -593,9 +595,31 @@ public static void ExportAssets(string savePath, List toExportAssets, } catch (Exception ex) { - MessageBox.Show($"Export {asset.Type}:{asset.Text} error\r\n{ex.Message}\r\n{ex.StackTrace}"); + try + { + string directory = AppDomain.CurrentDomain.BaseDirectory; + logFilePath = Path.Combine(directory, "log_error.txt"); + string prevLogFilePath = Path.Combine(directory, "log_error_prev.txt"); + if (!ExportError) + { + if (File.Exists(logFilePath)) + { + if (File.Exists(prevLogFilePath)) + { + File.Delete(prevLogFilePath); + } + File.Move(logFilePath, prevLogFilePath); + } + File.AppendAllText(logFilePath, $"Export Errors:" + $"Version {Application.ProductVersion}" + Environment.NewLine + $"----------" + Environment.NewLine); + ExportError = true; + }; + File.AppendAllText(logFilePath, $"Export {asset.Type}:{asset.Text} error\r\n{ex.Message}\r\n{ex.StackTrace}" + Environment.NewLine + Environment.NewLine); + } + catch (Exception ex2) + { + Console.WriteLine("Error saving to log file: " + ex2.Message); + } } - Progress.Report(++i, toExportCount); } @@ -605,6 +629,11 @@ public static void ExportAssets(string savePath, List toExportAssets, { statusText += $" {toExportCount - exportedCount} assets skipped (not extractable or files already exist)"; } + if (ExportError) + { + Process.Start("notepad.exe", logFilePath); + } + StatusStripUpdate(statusText);