Skip to content

Commit

Permalink
Load fields.txt and test-fields.txt from executable directory instead…
Browse files Browse the repository at this point in the history
… of working directory

This fixes issues such as where right clicking the taskbar icon and starting a new instance would fail to load fields as the working directory is not where the fields.txt file exists.
  • Loading branch information
ThiconZ committed Oct 26, 2024
1 parent e87fb04 commit 132ebb1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions SDBrowser/SDBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,16 +352,17 @@ private void LoadTableAndFieldNames()
// fields.txt holds strings we are confident have valid matches in some databases
// All of them will be added to the StringDB first.
// We store them in clearedStrings because our StringDB will also hold duplicates. This allows us to later highlight a column if we have multiple matches and haven't selected the one we think is right.
if (File.Exists("fields.txt"))
string exeDirectory = AppDomain.CurrentDomain.BaseDirectory;
if (File.Exists(Path.Combine(exeDirectory, "fields.txt")))
{
clearedStrings = File.ReadAllLines("fields.txt").ToList();
clearedStrings = File.ReadAllLines(Path.Combine(exeDirectory, "fields.txt")).ToList();
AddStringsToStringDB(clearedStrings);
}

// test-fields.txt can be used to add additional strings you want include for testing
if (File.Exists("test-fields.txt"))
if (File.Exists(Path.Combine(exeDirectory, "test-fields.txt")))
{
List<string> testStrings = File.ReadAllLines("test-fields.txt").ToList();
List<string> testStrings = File.ReadAllLines(Path.Combine(exeDirectory, "test-fields.txt")).ToList();
AddStringsToStringDB(testStrings);
}
}
Expand Down

0 comments on commit 132ebb1

Please sign in to comment.