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.
Namespace: DevCase.Core.IO.FileSystemAssembly: 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
)
Public Shared Function PreloadInIconCache (
dirPath As String,
Optional iconSize As IconSizes = IconSizes._256x256
) As Bitmap
Dim dirPath As String
Dim iconSize As IconSizes
Dim returnValue As Bitmap
returnValue = UtilDirectory.PreloadInIconCache(dirPath,
iconSize)
public:
static Bitmap^ PreloadInIconCache(
String^ dirPath,
IconSizes iconSize = IconSizes::_256x256
)
static member PreloadInIconCache :
dirPath : string *
?iconSize : IconSizes
(* Defaults:
let _iconSize = defaultArg iconSize IconSizes._256x256
*)
-> Bitmap
No code example is currently available or this language may not be supported.
- dirPath String
-
The directory path.
- iconSize IconSizes (Optional)
-
The requested icon size, in pixels.
Default value is 256.
Bitmap
The folder icon.
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
This is a code example.
No code example is currently available or this language may not be supported.
Dim directoryPath As String = "C:\Movies\"
Dim searchPattern As String = "*"
Dim searchOption As SearchOption = SearchOption.TopDirectoryOnly
Dim iconSize As IconSizes = IconSizes._256x256
For Each dir As DirectoryInfo In New DirectoryInfo(directoryPath).EnumerateDirectories(searchPattern, searchOption)
Console.WriteLine($"Preloading icon ({CStr(iconSize)}x{CStr(iconSize)}) for directory: '{dir.FullName}'")
Using icon As Bitmap = DirectoryUtil.PreloadInIconCache(dir.FullName, iconSize)
End Using
Next dir
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.