简体   繁体   中英

Get thumbnail of Network DWG file by Windows API Code Pack

I use the below code to get the DWG file thumbnail using the Windows API Code Pack:

ShellFile shellFile = ShellFile.FromFilePath(mediaInfo.Filename);
return shellFile.Thumbnail.LargeBitmap;

But this works for local DWG files only, and returns the blank document thumbnails for network based files.

However I see the thumbnails of network files via the Windows Explorer (I am on Win 8.1).

Any advice would be appreciated.

There must be something wrong happening on your side because the following code works here:

using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using Microsoft.WindowsAPICodePack.Shell;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string fileName = @"\\PC\Users\Public\bitmap.bmp";
            ShellFile shellFile = ShellFile.FromFilePath(fileName);
            ShellThumbnail thumbnail = shellFile.Thumbnail;
            var pictureBox = new PictureBox
            {
                Image = thumbnail.Bitmap,
                Dock = DockStyle.Fill
            };
            Controls.Add(pictureBox);
        }
    }
}

在此处输入图片说明

Check the following:

  • try with another extension to see if it affects all of them or not
  • try to re-register thumbnails handlers, just a guess but SageThumbs might fix this by registering it and unregistering it as the default handler for extensions
  • if that matters, I've used the Code Pack I've myself pushed to NuGet : https://www.nuget.org/packages/WindowsAPICodePack-Shell/ (not sure that might be the issue since I haven't changed anything)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM