I have created a 32-bit application in C#. Because it's 32-bit, it cannot access 64-bit locations such as C:\Windows\System32. To access 64-bit locations, I understand that I need to instead use C:\Windows\Sysnative.
I want to check if a file exists in System32. I placed a file there and can view it in my file explorer, so I know that it exists.
However, when I use the following code, the File.Exists method always returns false. Sysnative doesn't seem to be redirecting at all. How can I use File.Exists with both %windir% and Sysnative to find a file in System32 from a 32-bit app?
string fileName = "someFile.dll";
string path = Environment.ExpandEnvironmentVariables(@"%windir%\Sysnative\" + fileName);
//path should be 'C:\Windows\System32\'+fileName;
bool fileExists = File.Exists(path); //Always returns false