質問

I've a problem with an openFileDialog (default openFileDialog):

I've defined a filter (LogFiles|*.log) for my OpenFileDialog. Works fine, users can only select *.log file in a folder.

But, if these *.log files are in a zip archive, as the zip extension is natively recognized like a folder(CompressedFolder) by Windows and zip files displayed on the left Treeview of OpenFileDialog window, users are able to select the .*log files in the archive (and I don't want that!)

The filename returned par OpenFileDialog in this case is the filename of a temporary extracted file, so it seems not possible to test if the selected file is a zipEntry.

I only see 2 solutions to solve my problem:

1°) Accessing the registry, backup and removing the HKEY_CLASSES_ROOT.zip to restore it later (very bad solution!)

2°) As the OpenFileDialog is a sealed class, implement my own OpenFileDialog which prevent the display of *.log files inside a zip

Are there any other solutions?

Thanks.

役に立ちましたか?

解決

I've found a solution with the OpenFileDialog.AutoUpgradeEnabled property set to false.

With this setting, the left treeview of OpenFileDialog is not displayed (only shortcuts) and there's no more way to display the content of an archive if its extension is no allowed by the filter :-)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top