ExThe following code uses the Unzip method to unzip all the files from the zip file "c:\test\my test.zip" into the directory "c:\test\unzipped files". If the directory does not already exist, it will be created automatically. You should check the Unzip method's return value once you are done – if it is xerSuccess
(value 0) the operation was successful. Otherwise, look up the error code in the error codes list to find out what went wrong.
VC++ |
Copy Code |
#include "stdafx.h" #include <stdio.h> #import "xceedzip.dll" named_guids no_namespace
int main(int argc, char* argv[]) { CoInitialize( NULL );
try { IXceedZipPtr piXceedZip( CLSID_XceedZip ); piXceedZip->License( _bstr_t( L"your license key ) );
long xErr;
piXceedZip->ZipFilename = "c:\\test\\my test.zip"; piXceedZip->UnzipToFolder = "c:\\test\\unzipped files";
xErr = piXceedZip->Unzip();
if ( xErr == 0 ) // xerSuccess { printf( "All files unzipped successfully" ); } else { printf( "Error %08x occured while unzipping the files\n", xErr ); } } catch( const _com_error& xErr ) { printf( "COM error %08x. %S\n", xErr.Error(), ( const char* )xErr.Description() ); } catch( ... ) { printf( "Unexpected error\n" ); }
CoUninitialize(); return 0; } |