win7 的缩略图 thumbnail 使得文件管理更加直观,方便。 如果想在自己的程序中直接读取文件的thumbnail, .net framework 没有直接提供支持。 还好微软提供了Windows® API Code Pack for Microsoft® .NET Framework 可以支持读取文件的thumbnail缩略图。 可在此链接下载http://archive.msdn.microsoft.com/WindowsAPICodePack
解压后,将dll添加到项目引用。
用法如下:
using Microsoft.WindowsAPICodePack.Shell;
Bitmap _bitmap;
// 获得文件夹缩略图
_bitmap = ShellFileSystemFolder.FromFolderPath(/* folder path here */ ) .Thumbnail.Bitmap;
// 获得文件缩略图
Bitmap _bitmap = ShellFile.FromFilePath(System.IO.Path.Combine((/* filer path here */)).Thumbnail.Bitmap;