# HG changeset patch # User IBBoard # Date 1337454981 -3600 # Node ID 425912324be52d0dfb3db234e622e6156b05504a # Parent 2bde6d18d3bd927fdfbce537a75db09498794894 Re #417: Improve install/first use experience * Handle file copy errors in WinForms and tell user diff -r 2bde6d18d3bd -r 425912324be5 FrmMain.cs --- a/FrmMain.cs Sat May 19 16:46:19 2012 +0100 +++ b/FrmMain.cs Sat May 19 20:16:21 2012 +0100 @@ -3,6 +3,7 @@ // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. using System; +using System.Text; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; @@ -1507,15 +1508,44 @@ if (dr == DialogResult.OK) { + List exceptions = new List(); + foreach (string filePath in addDataFileDialog.FileNames) { - WarFoundryLoader.AddNewDataFile(filePath); + try + { + WarFoundryLoader.AddNewDataFile(filePath); + } + catch (Exception ex) + { + exceptions.Add(ex); + } } WarFoundryLoader.GetDefault().LoadFiles(); + + if (exceptions.Count > 0) + { + string errorMsg = MakeAddDataFileFailedMessage(exceptions); + MessageBox.Show(this, errorMsg, "errors adding new data files", MessageBoxButtons.OK, MessageBoxIcon.Error); + } } addDataFileDialog.Dispose(); } + + private string MakeAddDataFileFailedMessage(List exceptions) + { + StringBuilder sb = new StringBuilder(); + sb.Append("errors occurred while adding the new data files: "); + + foreach (Exception ex in exceptions) + { + sb.Append("\n\t"); + sb.Append(ex.Message); + } + + return sb.ToString(); + } } }