protected void LoadFile(string filePath) { try { if (!ScoreBook.IsCompatible(filePath)) { MessageBox.Show(this, "現在のバージョンでは開けないファイルです。", Program.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!ScoreBook.IsUpgradeNeeded(filePath)) { if (MessageBox.Show(this, "古いバージョンで作成されたファイルです。\nバージョンアップしてよろしいですか?\n(以前のバージョンでは開けなくなります。)", Program.ApplicationName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } } LoadBook(ScoreBook.LoadFile(filePath)); } catch (Exception ex) { MessageBox.Show(this, "ファイルの読み込み中にエラーが発生しました。", Program.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error); Program.DumpException(ex); LoadBook(new ScoreBook()); } }
protected void LoadFile(string filePath) { try { if (!ScoreBook.IsCompatible(filePath)) { MessageBox.Show(this, ErrorStrings.FileNotCompatible, Program.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (ScoreBook.IsUpgradeNeeded(filePath)) { if (MessageBox.Show(this, ErrorStrings.FileUpgradeNeeded, Program.ApplicationName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } } LoadBook(ScoreBook.LoadFile(filePath)); } catch (UnauthorizedAccessException) { MessageBox.Show(this, ErrorStrings.FileNotAccessible, Program.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error); LoadEmptyBook(); } catch (Exception ex) { MessageBox.Show(this, ErrorStrings.FileLoadError, Program.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error); Program.DumpExceptionTo(ex, "file_exception.json"); LoadEmptyBook(); } }
protected void LoadFile(string path) { try { if (!ScoreBook.IsCompatible(path)) { MessageBox.Show(this, "現在のバージョンでは開けないファイルです。", Program.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (ScoreBook.IsUpgradeNeeded(path)) { if (MessageBox.Show(this, "古いバージョンで作成されたファイルです。バージョンアップしてよろしいですか?\n(以前のバージョンでは開けなくなります。)", Program.ApplicationName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } } LoadBook(ScoreBook.LoadFile(path)); } catch (Exception ex) { MessageBox.Show(this, "ファイルを読み込むことができませんでした。", Program.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error); Program.DumpExceptionTo(ex, "file_exception.json"); LoadEmptyBook(); } }