Click or drag to resize

IFileSystemItemGetThumbnailAsync Method

IT Hit User File System
Called when thumbnail is requested by the platform.

Namespace:  ITHit.FileSystem
Assembly:  ITHit.FileSystem (in ITHit.FileSystem.dll) Version: 6.3.20496.0
Task<byte[]> GetThumbnailAsync(
	uint size


Type: SystemUInt32
Thumbnail size in pixels.

Return Value

Type: TaskByte
Thumbnail bitmap or null if no thumbnail should be displayed for this item.
NotImplementedExceptionIf no thumbnail should be displayed.

To show thumbnails in your virtual drive on Windows platform follow these steps:

  1. Derive your class from the [!:ThumbnailProviderHandlerBase] class. Add the GuidAttribute, ProgIdAttribute and ComVisibleAttribute attributes to your class. You do not need to implement any methods in your class.
  2. Add the desktop3:ThumbnailProviderHandler tag to your Package.appxmanifest (in case of packaged app) or appxmanifest.xml (in case of a sparse package) that references your class. Alternativly you can register your class as a COM component using regsvr32 or any other method.
  3. Implement the GetThumbnailAsync(UInt32) method to return the thumbnail bitmap data.

Thumbnails functionality does not require package or application identity.


The code below is part of 'WebDAVDrive' C# sample provided with the SDK.

public class ThumbnailProviderRpc : ThumbnailProviderHandlerRpcBase


The code below is part of 'WebDAVDrive' C# sample provided with the SDK.

  <desktop3:Extension Category="windows.cloudFiles">
      <desktop3:CustomStateHandler Clsid="754F334F-095C-46CD-B033-B2C0523D2829"/>
      <desktop3:ThumbnailProviderHandler Clsid="A5B0C82F-50AA-445C-A404-66DEB510E84B"/>

      <desktop3:ExtendedPropertyHandler Clsid="20000000-0000-0000-0000-000000000001"/>
      <desktop3:BannersHandler Clsid="20000000-0000-0000-0000-000000000001"/>

        <desktop3:Verb Id="LockCommand" Clsid="A22EBD03-343E-433C-98DF-372C6B3A1538" />

  <com:Extension Category="windows.comServer">
      <!-- When changing ProgId make sure to change it also in the ThumbnailProvider.cs -->

      <com:ExeServer DisplayName="WebDAVDrive.ShellExtension" Executable="WebDAVDrive.ShellExtension\WebDAVDrive.ShellExtension.exe">
        <com:Class Id="A5B0C82F-50AA-445C-A404-66DEB510E84B" />

      <com:ExeServer DisplayName="WebDAVDrive.ShellExtension" Executable="WebDAVDrive.ShellExtension\WebDAVDrive.ShellExtension.exe">
        <com:Class Id="A22EBD03-343E-433C-98DF-372C6B3A1538" />

      <com:ExeServer DisplayName="WebDAVDrive.ShellExtension" Executable="WebDAVDrive.ShellExtension\WebDAVDrive.ShellExtension.exe">
          <com:Class Id="754F334F-095C-46CD-B033-B2C0523D2829" />


The code below is part of 'WebDAVDrive' C# sample provided with the SDK.

public async Task<byte[]> GetThumbnailAsync(uint size)
    byte[] thumbnail = null;

    string[] exts = Program.Settings.RequestThumbnailsFor.Trim().Split("|");
    string ext = System.IO.Path.GetExtension(UserFileSystemPath).TrimStart('.');

    if (exts.Any(ext.Equals) || exts.Any("*".Equals))
        string ThumbnailGeneratorUrl = Program.Settings.ThumbnailGeneratorUrl.Replace("{thumbnail width}", "" + size).Replace("{thumbnail height}", "" + size);
        string filePathRemote = ThumbnailGeneratorUrl.Replace("{path to file}", WebDAVDrive.Mapping.MapPath(UserFileSystemPath));

            using (IWebResponse response = await Program.DavClient.DownloadAsync(new Uri(filePathRemote)))
                using (Stream stream = await response.GetResponseStreamAsync())
                    thumbnail = await StreamToByteArrayAsync(stream);
        catch (System.Net.WebException we)
            Logger.LogMessage(we.Message, UserFileSystemPath);
        catch (Exception e)
            Logger.LogError($"Failed to load thumbnail {size}px", UserFileSystemPath, null, e);

    string thumbnailResult = thumbnail != null ? "Success" : "Not Impl";
    Logger.LogMessage($"{nameof(VirtualEngine)}.{nameof(GetThumbnailAsync)}() - {thumbnailResult}", UserFileSystemPath);

    return thumbnail;

private static async Task<byte[]> StreamToByteArrayAsync(Stream stream)
    using (MemoryStream memoryStream = new())
        await stream.CopyToAsync(memoryStream);
        return memoryStream.ToArray();
See Also