The line is
if (!val.Contains(Environment.GetEnvironmentVariable("windir")))
Which seems to work just fine with a Windows 7(64-bit) system and will detect whether the string I'm looking at contains any version of c:\windows with any capitalization. But under XP, the same code does not seem to detect the changes in case. I have all the results printing to the console for debugging and some c:\WINDOWS are getting through, but when I execute
echo %windir%
in the Command window, I get C:\WINDOWS. Is there a way to rewrite my test so that it doesn't break compatibility with Win7 but will catch these differences with XP?
Thanks
I'd recommend using this instead to get the windows folder:
var windowsPath = Environment.GetFolderPath(Environment.SpecialFolder.Windows)
And you can do this for case-insensitive comparison:
if (val.IndexOf(windowsPath, StringComparison.InvariantCultureIgnoreCase) < 0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With