Skip to content

Commit

Permalink
JimEvans: Correcting FileUtilities.FindFile() to correctly return the…
Browse files Browse the repository at this point in the history
… current directory if the specified file is located there. This fixes an issue where driver service executables (IEDriverServer.exe and chromedriver.exe) would not be found if placed in the same directory as the WebDriver.dll assembly, breaking previous behavior.

r18278
  • Loading branch information
jimevans committed Dec 7, 2012
1 parent 0cb21d0 commit a5bc9c6
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions dotnet/src/WebDriver/Internal/FileUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,21 @@ public static string FindFile(string fileName)
{
// Look first in the same directory as the executing assembly
string currentDirectory = GetCurrentDirectory();
if (File.Exists(Path.Combine(currentDirectory, fileName)))
{
return currentDirectory;
}

// If it's not in the same directory as the executing assembly,
// try looking in the system path.
if (!File.Exists(Path.Combine(currentDirectory, fileName)))
string systemPath = Environment.GetEnvironmentVariable("PATH");
string[] directories = systemPath.Split(Path.PathSeparator);
foreach (string directory in directories)
{
string systemPath = Environment.GetEnvironmentVariable("PATH");
string[] directories = systemPath.Split(Path.PathSeparator);
foreach (string directory in directories)
if (File.Exists(Path.Combine(directory, fileName)))
{
if (File.Exists(Path.Combine(directory, fileName)))
{
currentDirectory = directory;
return currentDirectory;
}
currentDirectory = directory;
return currentDirectory;
}
}

Expand Down

0 comments on commit a5bc9c6

Please sign in to comment.