0

How can I use the file preview of the explorer for files or generate a preview with a library?

I have tried the Windows Codepack API, but when trying to get the preview for all kind of office docs, I only get the Icon of the office doc, although the windows explorer shows the preview of the file correctly (windows 10)

Heres my code:

            MemoryStream m = new MemoryStream();
            ShellFile shellFile = ShellFile.FromFilePath(absolutePath);
            shellFile.Thumbnail.FormatOption = ShellThumbnailFormatOption.ThumbnailOnly;
            Bitmap shellThumb = shellFile.Thumbnail.ExtraLargeBitmap;
            shellThumb.Save(m, ImageFormat.Png);

Corresponding to this post I tried to fix the issue, but the approaches that were shown there didnt work Windows API Code Pack - ShellFile not generating PDF bitmap

vazun
  • 194
  • 2
  • 15
  • Thumbnail != Preview. Which one do you need? – Steeeve Oct 30 '21 at 18:05
  • I need the preview – vazun Oct 30 '21 at 19:06
  • Then have a look at [How to get the IPreviewHandler for a file extension?](https://stackoverflow.com/questions/23633246/how-to-get-the-ipreviewhandler-for-a-file-extension). – Steeeve Oct 30 '21 at 19:46
  • Okay, know I installed the nuget package ShellShark, but what do I need to execute the code of the Methode ``GetShellClsidForFileType``? Furthermore, I am working in an asp net core application in combination class library, therefore I dont have an UI, and I want to keep this situation, unless there is no other way arround it, to get the preview... – vazun Nov 06 '21 at 19:34

0 Answers0