0

I'm building a windows C# Drive App, and wish to display the thumbnails for a handful of folders.

For files that exist in a drive, I know you can get the icon by using the IconLink parameter.

How can I do this file that doesn't exist (yet), using the MimeType of the file?

Tobiq
  • 2,489
  • 19
  • 38

2 Answers2

0

If you have the file extension you can get this from the registry, for example:

HKEY_CLASSES_ROOT
    .avi

On my machine, the (Default) value on that key is VLC.avi.

Now find the key with that name:

HKEY_CLASSES_ROOT
    VLC.avi

And there you should find a subkey called DefaultIcon, which in my case has a (Default) value of "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe",0

From here you should be able to get the icon from .exe path.

Sometimes DefaultIcon contains the path to a .dll followed by an index. For these you could check this SO question for details on how to extract the image itself.

Community
  • 1
  • 1
Bassie
  • 9,529
  • 8
  • 68
  • 159
0

You may want to try Uploading thumbnails. As discussed,

For shortcuts and other file types that Drive can't render, you can provide a thumbnail image generated by your application. Upload a thumbnail by setting the contentHints.thumbnail property on the File resource during an insert or update call as follows:

  • Set contentHints.thumbnail.image to the URL-safe Base64-encoded image
  • Set contentHints.thumbnail.mimeType to the appropriate type for the image format

If Drive can't generate a thumbnail, it will always use yours if you provided one.

In addition to that, note that thumbnails are invalidated each time the content of the file changes. When supplying thumbnails, it is important to upload new thumbnails each time the content is modified.

Also, check suggested solutions in the following SO posts and see if it will help you:

Community
  • 1
  • 1
Teyam
  • 7,686
  • 3
  • 15
  • 22