473,899 Members | 3,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

thumbnail of file (like explorer does)

Is there anyway to get a thumbnail of a file similar to the way explorer
does that can be used in an application? I want to for example if i drag a
file over a picture box, if it has the ability to have a thumbnail, show it
in the picture box.

thanks!
Nov 21 '05 #1
7 15614
Hi,

You will have to P/Invoke , look into the archives of
microsoft.publi c.dotnet.langua ges.csharp this was answer last week along
with a link to MSDN
take a look at www.pinvoke.net you will find there the signatures you need.

pd:
It's not a good thing to crosspost though.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Brian Henry" <no****@nospam. com> wrote in message
news:uF******** ******@TK2MSFTN GP15.phx.gbl...
Is there anyway to get a thumbnail of a file similar to the way explorer
does that can be used in an application? I want to for example if i drag a
file over a picture box, if it has the ability to have a thumbnail, show
it in the picture box.

thanks!

Nov 21 '05 #2

Brian Henry wrote:
Is there anyway to get a thumbnail of a file similar to the way explorer
does that can be used in an application? I want to for example if i drag a
file over a picture box, if it has the ability to have a thumbnail, show it
in the picture box.

thanks!


Some code I ran into on the web while looking for something just like
this:

// Please do not remove :)
// Written by Kourosh Derakshan
//
using System.IO;
using System.Drawing. Imaging;

private const int THUMBNAIL_DATA = 0x501B;
/// <summary>
/// Gets the thumbnail from the image metadata. Returns null of no
thumbnail
/// is stored in the image metadata
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
Image GetThumbnail (string path)
{
FileStream fs = File.OpenRead (path);
// Last parameter tells GDI+ not the load the actual image data
Image img = Image.FromStrea m (fs, false, false);
// GDI+ throws an error if we try to read a property when the image
// doesn't have that property. Check to make sure the thumbnail
property
// item exists.
bool propertyFound = false;
for (int i=0; i<img.PropertyI dList.Length; i++)
if (img.PropertyId List[i] == THUMBNAIL_DATA)
{
propertyFound = true;
break;
}

if (!propertyFound )
return null;

PropertyItem p = img.GetProperty Item (THUMBNAIL_DATA );
fs.Close();
img.Dispose();
// The image data is in the form of a byte array. Write all
// the bytes to a stream and create a new image from that stream
byte[] imageBytes = p.Value;
MemoryStream stream = new MemoryStream (imageBytes.Len gth);
stream.Write (imageBytes, 0, imageBytes.Leng th);

return Image.FromStrea m(stream);
}

A big thanks to Kourosh.

Matt

Nov 21 '05 #3
You need to use the shells IExtractImage interface.
This will show you how...
http://www.vbaccelerator.com/home/NE...on/article.asp
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Brian Henry" <no****@nospam. com> wrote in message
news:uF******** ******@TK2MSFTN GP15.phx.gbl...
Is there anyway to get a thumbnail of a file similar to the way explorer
does that can be used in an application? I want to for example if i drag a
file over a picture box, if it has the ability to have a thumbnail, show
it in the picture box.

thanks!

Nov 21 '05 #4
well that works the best so far, I can get it to give me a thumb of a DOC
and Visio file which I need, but I also need PDF thumbs (Acrobat 7 does
thumbs now) and when i select a pdf with that test app it says "Failed to
get thumbnail: The data necessary to complete this operation is not yet
available."
Nov 21 '05 #5
Are the thumbnails visible in the explorer window? If they are they should
be extractable by this method. If the thumbnails are just specific to the
file open dialog in acrobat I would suspect a custom implementation rather
than a shell integration solution.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Brian Henry" <no****@nospam. com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
well that works the best so far, I can get it to give me a thumb of a DOC
and Visio file which I need, but I also need PDF thumbs (Acrobat 7 does
thumbs now) and when i select a pdf with that test app it says "Failed to
get thumbnail: The data necessary to complete this operation is not yet
available."

Nov 21 '05 #6
yes, they are visible in explorer under acrobat reader 7
"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Are the thumbnails visible in the explorer window? If they are they should
be extractable by this method. If the thumbnails are just specific to the
file open dialog in acrobat I would suspect a custom implementation rather
than a shell integration solution.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Brian Henry" <no****@nospam. com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
well that works the best so far, I can get it to give me a thumb of a DOC
and Visio file which I need, but I also need PDF thumbs (Acrobat 7 does
thumbs now) and when i select a pdf with that test app it says "Failed to
get thumbnail: The data necessary to complete this operation is not yet
available."


Nov 21 '05 #7
Use the IExtractImage interface via P/Interop.

-Atul, Sky Software http://www.ssware.com
Shell MegaPack ActiveX & .Net
Drop In Windows Explorer like Shell Browsing GUI controls for your app.

"Brian Henry" <no****@nospam. com> wrote in message
news:uF******** ******@TK2MSFTN GP15.phx.gbl...
Is there anyway to get a thumbnail of a file similar to the way explorer
does that can be used in an application? I want to for example if i drag a
file over a picture box, if it has the ability to have a thumbnail, show
it in the picture box.

thanks!

Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
5624
by: Mike | last post by:
Sites using thumbnail preview for world wide web file navigation and searching. Below are list of sites that are either researching or providing thumbnail preview images for online web documents. Thumbnail previews are useful for web site navigation particularly in search engines and directories such as Google, Altavista and Yahoo. The preview images provide a portion of the content of the electronic file to aid in navigation.
1
4937
by: Ole | last post by:
Hi all, I'm trying to design a control which would display the thumbnail of a specific file (FileName property), just like the windows explorer does, i.e if no thumbnail is available it does show the large file icon. I suppose I can use a Windows API to do this, but I just can't find which one... I've already seen several answers to this question, but I could apply
5
5901
by: Brian Henry | last post by:
Is there anyway to get a thumbnail of a file similar to the way explorer does that can be used in an application? I want to for example if i drag a file over a picture box, if it has the ability to have a thumbnail, show it in the picture box. thanks!
2
4590
by: Mark R. Dawson | last post by:
Hi all, I have a directory full of images (most over 2MB in size) I was to show each image as a thumbnail on a form, however in order to create a thumbnail I have to open the complete image then scale it down. This is quite slow, since there is a lot of file IO going on, what I want to be able to do is open the image in the scaled down size so that I miss out the step of opening the file then dowsizing it. I have not been able to find...
4
1366
by: moondaddy | last post by:
I have an app where users will upload photos to their shopping cart. When they review their cart I need to include a light weight thumbnail of the image they uploaded. how can I take the image a user uploaded (PixOfMom.jpg at 600k) and convert it to a thumbnail and put into the image url of a .net image control using vb.net 1.1? Thanks! -- moondaddy@nospam.com
1
3248
by: Xah Lee | last post by:
The following is a program to generate thumbnail images for a website. Useful, if you want to do that. It is used to generate the thumbnails for my “Banners, Damsels, and Mores” project gallery. ( http://xahlee.org/Periodic_dosage_dir/lanci/lanci.html ) Comments and versions in other lang welcome. Xah
8
20387
by: barb | last post by:
So that the world at large benefits from our efforts, here is one fully documented way to use Windows Irfanview freeware to create thumbnail web galleries (http://www.irfanview.com). STEP 1: Start with original thumbnails & two empty sub directories STEP 2: Create smaller versions of the originals for one sub directory STEP 3: Create thumbnail version of the originals the other sub directory STEP 4: Create an index.html pointing to the...
7
2359
by: oscartheduck | last post by:
Hi folks, I'm trying to alter a program I posted about a few days ago. It creates thumbnail images from master images. Nice and simple. To make sure I can match all variations in spelling of jpeg, and different cases, I'm using regular expressions. The code is currently:
1
1805
by: Mark | last post by:
I am trying to show many Images in a Listview controls with size(100,100). But some of the images sizes are big, like width=238 and height 50. These images does not appear proper in the listview control. What do I need to do to see the Images same as I am looking using windows explorer thumbnail. Please help me as I am stuck on this for almost two days now. Thanks for any help you can provide.
10
2187
by: Mike Copeland | last post by:
On my main page I have a small picture - it's actually too small to be useful. I only have it there to show that there's something to look at, but I don't know how to "expand" it so it can be seen in a reasonable size. Here's my code so far: <img src="IMG_0492.jpg" width="56" height="70" align="left" hspace="5" /> This picture consumes the whole screen (it's 952KB) when I click on the file in Explorer, and I want the same sort of...
0
9845
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10866
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9671
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8043
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7204
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4721
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4301
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3320
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.