Wasn’t sure whether this was better asked at StackOverflow or here, but I believe it’s more an operating system problem.
I have a Windows 11 machine running with the shell replaced with a proprietary application. (.NET, WPF)
Windows 11 IoT Enterprise LTSC 24H2
One of the features of the application is to save reports as PDF files. We open the Save File dialogue box with its Windows Explorer interface, filtering by *.pdf, and for some reason, the UI hangs for several seconds while it loads the list of existing files. It then displays the screen with the list of files and folders, slowly populating, and if you try to do anything like drag the scroll bar. It freezes for several seconds again. Eventually everything settles down and you can scroll up and down and type in the text box, but if you try to enter another folder, it restarts the whole process hanging and all.
Strangely though, if I filter by another extension/file type – e.g. *.zip instead of *.pdf I don’t have this problem. I also don’t have it if running as another user whose shell is not replaced (i.e. uses the normal explorer.exe)
From what I gather, Windows tries to read PDFs while listing the files in Explorer.
What I’ve tried:
-
using
shexviewto disable the “PDF Preview Handler” shell extension. -
Removing
HKEY_CLASSES_ROOT.pdfShellEx{8895b1c6-b41f-4c1c-a562-0d564250836f}which contained the GUID of the above PDF Preview Handler extension -
Including a reference to the IWin32 window in the
ShowDialogcall… e.g.saveFileDialog.ShowDialog(window)as suggested by an AI who shall remain nameless -
The following parameters for creating the dialogue box also suggested by AI…
OverwritePrompt = true, ValidateNames = true, CheckPathExists = true
Why would I have this issue with PDFs but not with Zips and how can I prevent it? I don’t need any PDF preview type stuff, just a freely operating Save File dialogue box so the user can type in file names and browse folders without it hanging.
Really weird update
Through some playing around, I’ve found that if, in the Explorer options, I enable “Hide extensions for known file types”, the problem goes away!
Not the complete solution (as I’d like the user to be able to view the extensions) and still doesn’t explain why it was happening, but still…
Note: I launched explorer.exe to try this, but then restarted the device to ensure explorer wasn’t running while I tested with the update, just to be sure it wasn’t “fixed” because explorer was running in the background