Created
March 19, 2012 15:15
-
-
Save jamesrcounts/2115876 to your computer and use it in GitHub Desktop.
A patch that corrects GetPathInProgramFilesX86 behavior in a process compiled for x86
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When the test project is compiled for x86, Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) and Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) both return "C:\Program Files (x86)" | |
on an x64 machine. As a result, the ternary expression does not end up helping find x64 versions of the utilities ApprovalTests is looking for. | |
However, Environment.GetEnvironmentVariable("ProgramW6432") returns "C:\Program Files" even when the test assembly is compiled for x86 and ApprovalTests is able to find x64 utilities. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: BeyondCompareReporter.cs | |
=================================================================== | |
--- BeyondCompareReporter.cs (revision 378) | |
+++ BeyondCompareReporter.cs (working copy) | |
@@ -20,7 +20,7 @@ | |
public static string GetPathInProgramFilesX86(string path) | |
{ | |
var x86Path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + @"\" + path; | |
- return File.Exists(x86Path) ? x86Path : Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + @"\" + path; | |
+ return File.Exists(x86Path) ? x86Path : Environment.GetEnvironmentVariable("ProgramW6432") + @"\" + path; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment