Skip to content

Commit

Permalink
Update UsefulStuff.cs
Browse files Browse the repository at this point in the history
Fix BaseDirectory access, avoid Assembly.Location entirely since compiler objects now
  • Loading branch information
jas88 committed Jul 20, 2023
1 parent 156735c commit 357256f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Rdmp.Core/ReusableLibraryCode/UsefulStuff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static bool IsBasicallyNull(this string result)

public static bool IsBadName(string name)
{
return name != null && name.Any(c => Path.GetInvalidFileNameChars().Contains(c));
return name?.Any(Path.GetInvalidFileNameChars().Contains) == true;
}

public static void OpenUrl(string url)
Expand Down Expand Up @@ -206,9 +206,7 @@ private static char GetCHICheckDigit(string sCHI)

public static DirectoryInfo GetExecutableDirectory()
{
return !string.IsNullOrWhiteSpace(AppDomain.CurrentDomain.BaseDirectory)
? new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory)
: new DirectoryInfo(typeof(UsefulStuff).Assembly.Location);
return new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory ?? throw new Exception("BaseDirectory was null?!"));
}

public static string HashFile(string filename, int retryCount = 6)
Expand Down

0 comments on commit 357256f

Please sign in to comment.