Why does Windows Explorer read files when I
When you're browsing a directory in Windows Explorer, it will typically attempt to generate icons for, and obtain other metadata about, the files in that directory. This only requires a very small portion of a file to be read rather than the whole file, but even so, the ReadFile event will fire and your application must handle it. If such behavior is not desirable, there are some strategies you can employ to help mitigate it:
- Include the STGMP_NETWORK flag when calling the AddMountingPoint method; this will create a "network mounting point", and Windows Explorer does its best to minimize the number requests it makes against such mounting points by default.
- Report that the files in your virtual filesystem have the FILE_ATTRIBUTE_OFFLINE attribute. Windows Explorer won't attempt to generate thumbnails for offline files. However, keep in mind that Windows Explorer will visibly mark (i.e., display an overlay on the icon of) any file with this attribute, so this solution may not be desirable for that reason.
- Proactively cache the information that Windows Explorer will request so that you can quickly handle the ReadFile events during directory enumeration.
- For some types of drives/mounting points, Windows Explorer will create a thumbs.db file within the drive and use it to cache thumbnail data. Your application can attempt to pre-create this file, or store it somewhere it can be accessed quickly.
We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at firstname.lastname@example.org.