C # decompress the zip file

Source: Internet
Author: User

1. decompression method Reprinted from the http://www.bkjia.com/kf/201204/128704.html

"C#decompress The. ZIP file. A lot of methods are found on the Internet, using System. IO. compression. GZipStream uses the J # library function and the Java-based library function. However, many of them are not very good. In the end, it is still the System function System. shell. folder. copyHere (oItem [, intOptions]) is the best choice. The specific method is as follows:

1. Add the reference Shell32.dll, which can be found in Windows \ system32.
2. Add the method.

Static void UnZip (string zipFile, string destFolder)
{
Shell32.ShellClass SC = new Shell32.ShellClass ();
Shell32.Folder SrcFolder = SC. NameSpace (zipFile );
Shell32.Folder DestFolder = SC. NameSpace (destFolder );
Shell32.FolderItems items = SrcFolder. Items ();
DestFolder. CopyHere (items, 20 );
}

(Note that destFolder must exist in advance. This method will not automatically create a folder)

DestFolder. in CopyHere (items, 20), 20 is actually an intOptions flags (4 | 16). 4 indicates that the processing window is not displayed, 16. If the processing window is displayed, select "yes to all ". For more information about intOptions, visit http://msdn2.microsoft.com/en-us/library/ms723207.aspx. "

 

2. "In VS2010, the interoperability type"... "cannot be embedded. Please switch to the applicable interface solution "solution reproduced from the http://www.bkjia.com/kf/201204/128705.html

"Recently, VS2010 was used. When COM components were referenced, the"… ", Use the error message of the applicable interface instead. Check the information and find the solution. The record is as follows:

Right-click the dll introduced in the project, select properties, and set "embedded interoperability type" to False. "

 

From Fengfeng

Related Article

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.