How can I access windows file preview icons from my WPF application

℡╲_俬逩灬. 提交于 2021-02-18 00:54:26

问题


I got a bunch of Pictures and Videos in a directory and needs to be displayed in the WPF application, I am thinking about displaying the Win7 Large Icon itself as the preview image. Because that will save me the work of grabbing an appropriate frame from the video file since Windows is doing that job pretty well already. Any code snippet to access this Shell Icon image data?


回答1:


When using the Windows API Code Pack, you can do:

XAML

 <Image x:Name="img" />

C#

 img.Source = ShellFile.FromFilePath(@"C:\path\to\file.ext").Thumbnail.BitmapSource;

This requires adding the Microsoft-WindowsAPICodePack-Shell package and the appropriate namespaces.



来源:https://stackoverflow.com/questions/2987625/how-can-i-access-windows-file-preview-icons-from-my-wpf-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!