简体   繁体   English

通过Windows API代码包获取网络DWG文件的缩略图

[英]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: 我使用以下代码通过Windows API代码包获取DWG文件缩略图:

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. 但这仅适用于本地DWG文件,并返回基于网络的文件的空白文档缩略图。

However I see the thumbnails of network files via the Windows Explorer (I am on Win 8.1). 但是,我可以通过Windows资源管理器看到网络文件的缩略图(我在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 尝试重新注册缩略图处理程序,只是一个猜测,但是SageThumbs可以通过注册它并将其注销为扩展的默认处理程序来解决此问题。
  • 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) 如果那很重要,我就使用我自己推送到NuGet的代码包: https : //www.nuget.org/packages/WindowsAPICodePack-Shell/ (不确定这是问题所在,因为我没有做任何更改)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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