UtilDirectoryPreloadInIconCache Method

Preloads the icon of a directory into Windows Icon Cache system files (IconCache_xxx.db).

The folder must contain a "desktop.ini" file with the icon specified.

Definition

Namespace: DevCase.Core.IO.FileSystem
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
public static Bitmap PreloadInIconCache(
	string dirPath,
	IconSizes iconSize = IconSizes._256x256
)

Parameters

dirPath  String
The directory path.
iconSize  IconSizes  (Optional)
The requested icon size, in pixels.

Default value is 256.

Return Value

Bitmap
The folder icon.

Remarks

Because the Windows Icon Cache system creates icon's entry hashes with some kind of process architecture differentiation, the user must make sure to call PreloadInIconCache(String, IconSizes) function from a process that matches the same architecture of the running operating system.

In short, PreloadInIconCache(String, IconSizes) function should be called from a x64 process if running under Windows x64, and from a x86 process if running under Windows x86.

Otherwise, if for example PreloadInIconCache(String, IconSizes) function is called from a x86 process if running under Windows x64, it will happen that when accesing the specified folder via Explorer.exe, the operating system will ignore the icon cached using PreloadInIconCache(String, IconSizes) function, and it will cache again the folder, generating a new additional entry in the Icon Cache system files (C:\Users\{NAME}\AppData\Local\Microsoft\Windows\Explorer\IconCache_xxx.db).

Read more about this problem at: https://stackoverflow.com/a/66773765/1248295

Example

This is a code example.
C#
No code example is currently available or this language may not be supported.

See Also