Fail properly when ext. tools dir is missing (fixes #2787 for real)

This commit is contained in:
YoshiRulz 2021-06-11 02:09:16 +10:00
parent 07fd664485
commit 93ca66a243
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 15 additions and 16 deletions

View File

@ -35,29 +35,28 @@ namespace BizHawk.Client.EmuHawk
DirectoryMonitor.Created -= DirectoryMonitor_Created;
DirectoryMonitor.Dispose();
}
DirectoryMonitor = new FileSystemWatcher(_paths["Global", "External Tools"].Path, "*.dll")
var path = _paths["Global", "External Tools"].Path;
if (Directory.Exists(path))
{
IncludeSubdirectories = false,
NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName,
Filter = "*.dll"
};
DirectoryMonitor.Created += DirectoryMonitor_Created;
DirectoryMonitor.EnableRaisingEvents = true;
DirectoryMonitor = new FileSystemWatcher(path, "*.dll")
{
IncludeSubdirectories = false,
NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName,
Filter = "*.dll"
};
DirectoryMonitor.Created += DirectoryMonitor_Created;
DirectoryMonitor.EnableRaisingEvents = true;
}
BuildToolStrip();
}
internal void BuildToolStrip()
{
MenuItems.Clear();
if (Directory.Exists(DirectoryMonitor.Path))
{
DirectoryInfo dInfo = new DirectoryInfo(DirectoryMonitor.Path);
foreach (FileInfo fi in dInfo.GetFiles("*.dll"))
{
MenuItems.Add(GenerateToolTipFromFileName(fi.FullName));
}
}
if (DirectoryMonitor == null) return;
DirectoryInfo di = new(DirectoryMonitor.Path);
if (!di.Exists) return;
foreach (var fi in di.GetFiles("*.dll")) MenuItems.Add(GenerateToolTipFromFileName(fi.FullName));
}
/// <summary>Generates a <see cref="ToolStripMenuItem"/> from an assembly at <paramref name="fileName"/> containing an external tool.</summary>