Use NPOI to read the Thumbs. dll file (1)

Source: Internet
Author: User

Thumbs. dll is a thumbnail file in the XP system (because Windows 7 is used and this file is not found for a long time, so I guess it may be stored in another file method in Windows 7 ), generally, it is stored in the image directory. The reason is that it is an alternative reading, because we use an Open Source component called the NPOI component (everyone in the garden should know it ), this is a component written by tony qu and the other two people. It is mainly used to operate excel files. I used this component to write a file grabbing tool a few days ago. It feels easier to use it, the key point is that you do not need to perform data connections and directly perform file operations, which brings us great convenience. Back to the question, we can use NPOI to operate thumbs. dll because it is an OLE2 document. We can first use the POIFS Browser open-source tool to determine whether the current file is an OLE2 document.

With this tool, we can see thumbs. dll is a standard OLE2 file, so that we can use NPOI to read this file. First, we need to download the latest DLL from NOPI, the tool we use is VS2008 SP1.

1. We will first reference 4 DLL:

2. After referencing the corresponding DLL, we can write the corresponding code.

Code

Namespace ConsoleApplicationNPOI
{
Class Program
{
Static void Main (string [] args)
{

Using (var stream = File. OpenRead ("F: \ unfinished \ Thumbs. db "))
{
POIFSFileSystem _ currentFileSystem = new POIFSFileSystem (stream );

DirectoryNode node = _ currentFileSystem. Root;

Var entries = node. Entries;

DocumentNode en;

String s = string. Empty;

While (entries. MoveNext ())
{
En = entries. Current as DocumentNode;

Var viewableArray = en. Document. ViewableArray;

S + = viewableArray. GetValue (0). ToString ();

Break;
}
Console. Write (s );
Console. ReadLine ();
}
}
}
}

 

 

3. Let's take a look at the running results:

4. From the running results, we know that thumbnails should be stored in JFIF format, and JFIF is one of the image storage formats, evolved from JPEG. As for how to convert the JFIF format to JPEG, we will present it to you later.

From the code, we can find that, just a few simple calls, we can all output streams of the file, but NPOI is far more powerful than this, I just used a small part of it. If you want more in-depth understanding, you can learn more through the http://www.cnblogs.com/tonyqus/archive/2009/04/12/1434209.html link.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.