Add empty file handling

This commit is contained in:
2022-11-28 23:17:58 +08:00
parent b05269712a
commit a2494b59f7

View File

@ -81,6 +81,7 @@ namespace GrasscutterTools.Forms
} }
catch (Exception ex) catch (Exception ex)
{ {
LoadBanners(Encoding.UTF8.GetString(Resources.Banners));
MessageBox.Show(ex.ToString(), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.ToString(), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
@ -129,7 +130,10 @@ namespace GrasscutterTools.Forms
return; return;
} }
LoadBanners(File.ReadAllText(path)); var content = File.ReadAllText(path);
if (string.IsNullOrEmpty(content))
content = Encoding.UTF8.GetString(Resources.Banners);
LoadBanners(content);
MessageBox.Show("OK", Resources.Tips, MessageBoxButtons.OK); MessageBox.Show("OK", Resources.Tips, MessageBoxButtons.OK);
} }
catch (Exception ex) catch (Exception ex)