Skip to content

Commit

Permalink
FileUtilities.GetCurrentDirectory reflection fix
Browse files Browse the repository at this point in the history
Fix for "The path is not of a legal form" exception when calling FileUtilities.GetCurrentDirectory using reflection

This was caused by an empty string being passed to System.IO.Path.GetDirectoryName

Fixes #3447

Signed-off-by: Jim Evans <[email protected]>
  • Loading branch information
mathlang authored and jimevans committed Jun 1, 2019
1 parent c29052b commit c0b01df
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion dotnet/src/webdriver/Internal/FileUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,14 @@ public static string FindFile(string fileName)
public static string GetCurrentDirectory()
{
Assembly executingAssembly = typeof(FileUtilities).Assembly;
string location = Path.GetDirectoryName(executingAssembly.Location);
string location = null;

// Make sure not to call Path.GetDirectoryName if assembly location is null or empty
if (!string.IsNullOrEmpty(executingAssembly.Location))
{
location = Path.GetDirectoryName(executingAssembly.Location);
}

if (string.IsNullOrEmpty(location))
{
// If there is no location information from the executing
Expand Down

0 comments on commit c0b01df

Please sign in to comment.