OpenFileDialog showing different files depending on the assembly for 32-bit or 64-bit architecture

I noticed that OpenFileDialog does not show all the files in the directory, this happens in my application, as well as in other Windows programs, such as the New Task task manager, Browse (which uses the OpenFileDialog control), does anyone know the reason and possible workarounds for this?
Even starting task manager as an administrator did not fix it, so it is not caused by privileges that seem

Edit: Now I know that this is caused by the appcompat function called File File Redirector , apparently I started the 32bit Task Manager, as well as my own application, and therefore it showed me the 32-bit system32 as well as the SysWOW64 folder (tell me about wierd naming schemes, in Windows 7 64-bit System32 has 64-bit files, and SysWOW64 contains 32-bit files), and it seems that when you have a 32-bit build of a specific application, you do not have access to the 64-bit System32 folder using OpenFileDialog .

As an example, here you can see that its missing SnippingTool.exe (but it is not limited to)

TaskManager OpenFileDialog Although I'm sure it exists in the target location
Windows explorer

+4
source share
1 answer

This happens when you run your code on a 64-bit version of Windows. The navigation bar says that you are looking at c: \ windows \ system32. But you really see the contents of c: \ windows \ syswow64. The same thing happens when you go to the c: \ program files. In fact, you will see the contents of c: \ program files (x86). There is no 32-bit version of SnippingTool.exe, therefore it is not listed.

This is an appcompat function called File System Redirection . Designed to give 32-bit programs a chance to survive in a 64-bit operating system.

You disable it by allowing your program to run as a 64-bit process. Right-click the EXE project, Properties tab, Create. Change the target platform setting to AnyCPU. On VS2012 and up, disable the "Prefer 32-bit" option.

+6
source

Source: https://habr.com/ru/post/1498748/


All Articles