I have a strange issue using File.Exists in C#, reproducable on several PC's. I see it as an error in the .NET 4 library.
I use 7ZIP and automate it from a C# program, I call CreateProcess and zip and unzip files with it. For that, I need to find out if and where 7ZIP is installed, because I don't want to depend on PATH variables.
So this is part of the code:
if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\7-Zip\\7z.exe"))
clsGlobal.gstr_ZIP_PROG_MIT_PFAD = "\"" + Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\7-Zip\\7z.exe\"";
else if (File.Exists("\"C:\\Program Files (x86)\\7-Zip\\7z.exe\""))
clsGlobal.gstr_ZIP_PROG_MIT_PFAD = "\"C:\\Program Files (x86)\\7-Zip\\7z.exe\"";
All Exist-Checks give me "false" back. The ProgramFiles-SpecialFolder points to the right (x86)-Folder, for sure. And also for sure, 7ZIP is installed in C:\Program Files (x86)\7-ZIP\7z.exe, and when calling CreateProcess, everything works fine. What can be the reason why all Exists() - Checks fail ? Is this a known bug ?