Skip to content

Commit ab03ef8

Browse files
authored
Fix for error "Source and destination path must have identical roots. Move will not work across volumes" (#146)
1 parent ad60c35 commit ab03ef8

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

WebDriverManager/Services/Impl/BinaryService.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,9 @@ public string SetupBinary(string url, string zipPath, string binaryPath)
7171
#endif
7272

7373
//
74-
// Create the destination parent directory if it doesn't exist
74+
// Create the destination directory if it doesn't exist
7575
//
76-
var binaryParentDir = Path.GetDirectoryName(binaryDir);
77-
Directory.CreateDirectory(binaryParentDir);
76+
Directory.CreateDirectory(binaryDir);
7877

7978
//
8079
// Atomically rename the staging directory to the destination directory
@@ -85,7 +84,16 @@ public string SetupBinary(string url, string zipPath, string binaryPath)
8584
Exception renameException = null;
8685
try
8786
{
88-
Directory.Move(stagingDir, binaryDir);
87+
string[] files = Directory.GetFiles(stagingDir);
88+
89+
// Copy the files and overwrite destination files if they already exist.
90+
foreach (string file in files)
91+
{
92+
// Use static Path methods to extract only the file name from the path.
93+
var fileName = Path.GetFileName(file);
94+
var destFile = Path.Combine(binaryDir, fileName);
95+
File.Copy(file, destFile, true);
96+
}
8997
}
9098
catch (Exception ex)
9199
{

0 commit comments

Comments
 (0)