Welcome to ComponentOne Zip for .NET

Untitled Document ComponentOne Zip for .NET Untitled Document E-mail sent to documentation@componentone.com is for documentation feedback only. We welcome any suggestions to help improve our documentation.

Welcome to ComponentOne Zip for .NET

ComponentOne Zip™ for .NET implements several classes that allow you to add data compression to your applications.

If you like Zip for .NET, you can check out our other products by visiting our web site at www.componentone.com.

ComponentOne has a user-friendly distribution policy. We want every Visual Studio programmer to get copies of our products and try them for as long as they want. Those who like the tools and find them useful can buy licenses at reasonable prices. The only restriction is that unlicensed copies of the software will display a ComponentOne banner when they are loaded, as a friendly reminder that we do expect people to pay for the software if they use it on a regular basis.

We are confident that you will like Zip For .NET. If you have any suggestions or ideas for new features that you'd like to see included in a future version, or ideas for new controls, please call us or write:

Corporate Headquarters

ComponentOne LLC
201 South Highland Avenue
3rd Floor
Pittsburgh, PA 15206 • USA
412.681.4343
412.681.4384 (Fax)

http://www.componentone.com

Overview

What's New in ComponentOne Zip for .NET

Installing Zip for .NET

End-User License Agreement for ComponentOne Software

Licensing FAQs

Technical Support

Redistributable Files

Namespaces

Creating a .NET Project

Adding a Reference to the C1Zip Assembly

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Overview

Overview

The classes in the C1Zip library are divided into three levels:

Level | Main Classes | Description
High | C1ZipFile, C1ZipEntry, C1ZipEntryCollection | Use these classes to create, open, and manage ZIP files. You can inspect the contents of zip files, test their integrity, add, delete, and extract entries to and from ZIP files.
Medium | C1ZStreamReader, C1ZStreamWriter | Use these classes to compress and expand data into and out of regular .NET streams (including memory, file, and network streams).
Low | ZStream | This is the lowest level class in C1Zip. It is a 100% C# implementation of Zlib, the popular data-compression library written by Jean-loup Gailly and Mark Adler. ZStream is used by the higher level classes in C1Zip.
Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


The C1ZipFile, C1ZipEntry and C1ZipEntryCollection Classes

The C1ZipFile, C1ZipEntry and C1ZipEntryCollection Classes

These are the highest level classes in the C1Zip library. They allow you to create and manage zip files. Using zip files to store application data provides the following benefits:

· You can consolidate many files into one, making application deployment easier.

· You can compress the data, saving disk space and network bandwidth.

· The zip format is an open standard, supported by many popular applications.

The C1ZipFile class encapsulates a zip file. After you create a C1ZipFile object, you can attach it to an existing zip file or tell it to create a new empty zip file for you. For example:

· Visual Basic

· C#

· Delphi

After you have created or opened a zip file, use the Entries collection to inspect the contents of the zip file, or to add, expand, and delete entries. For example:

· Visual Basic

· C#

· Delphi

The C1ZipEntry class exposes properties and methods that describe each entry, including its original file name, size, compressed size, etc. It also has a OpenReader method that returns a stream object, so you can read the entry contents without expanding it first.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


The C1ZStreamReader and C1ZStreamWriter Classes

The C1ZStreamReader and C1ZStreamWriter Classes

These classes allow you to use data compression on any .NET streams, not only in zip files.

To use C1ZStreamReader and C1ZStreamWriter objects, attach them to regular streams and read or write the data through them. The data is compressed (or expanded) on the fly into (or out of) the underlying stream.

This design allows great integration with native .NET streams. The diagram below illustrates how it works:

For example, the code below saves an ADO.NET DataTable object into a stream and then reads it back:

· Visual Basic

· C#

· Delphi

To add data compression, you would simply add two lines of code:

· Visual Basic

· C#

· Delphi

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


The ZStream Class

The ZStream Class

This is the lowest-level class in the C1Zip library, and it is used extensively by the higher-level classes described above.

Most users wwill never need to use ZStream directly. It is the most flexible, but the hardest to use component in the C1Zip library. ZStream is a C# implementation of the ZLIB library. ZLIB is an open-source library written by Jean-loup Gailly and Mark Adler.

For more information on ZLIB, check http://www.info-zip.org/ or http://www.gzip.org/.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


What's New in ComponentOne Zip for .NET

What's New in ComponentOne Zip for .NET

This documentation was last revised on June 15, 2005.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Feature Overview

Feature Overview

There are no new features in Zip for .NET at this time.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Class Members

Class Members

Below are the most recent class members added to the C1Zip component (the additions were updated on 10/15/2004):

C1Zip Class Members | Description
C1ZipFile.OpenBatch Method | Opens the zip file for multiple operations.
C1ZipFile.CloseBatch Method | Closes a zip file after it was opened with a call to the C1ZipFile.OpenBatch Method.
C1ZipFile.MemoryThreshold Property | Gets or sets the size of the largest stream to be compressed in memory.
C1ZipFile.TempFileName Property | Gets or sets the name of the temporary file to use when adding entries to the zip file.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Installing Zip for .NET

Installing Zip for .NET

The following sections provide helpful information on installing Zip for .NET.

Zip for .NET Setup Files

System Requirements

Installing Demonstration Versions

Uninstalling C1Zip for .NET

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Zip for .NET Setup Files

Zip for .NET Setup Files

To install Zip for .NET, run the C1Zip.msi installation file provided in the distribution CD (or downloaded from the Web), and follow the instructions.

The installation program will create a directory called "ComponentOne Studio.NET" under "Program Files". This directory will contain the following subdirectories:

bin | Contains copies of all binaries (DLLs, EXEs) in the ComponentOne Visual Studio.NET package.
Common | Contains support and data files that are used by many of the demo programs.
Demos | Contains demo projects for all Studio components.
Help | Contains online documentation for all Studio components.
C1Zip | Contains samples for C1Zip.
Other | Samples and tutorials for the other Studio components.
Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


System Requirements

System Requirements

· Operating Systems:

-Windows 2000

-Windows 2003 Server

-Windows NT 4

-Windows XP, sp1, sp2

· Environments:

-.NET Framework 1.0

-.NET Framework1.1

-C# .NET

-Delphi

-Visual Basic .NET

· Hard Disk Space: 5 MB hard disk space for storage of the software

· Disc Drive: CD or DVD-ROM drive if installing from CD

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Installing Demonstration Versions

Installing Demonstration Versions

If you wish to try C1Zip for .NET or any of our other products and do not have a registration key, follow the steps through the installation wizard and use the default serial number.

The only difference between unregistered (demonstration) and registered (purchased) versions of our products is that registered versions will stamp every application you compile so a ComponentOne banner will not appear when your users run the applications.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Uninstalling C1Zip for .NET

Uninstalling C1Zip for .NET

To uninstall C1Zip for .NET, open the Control Panel application, select the Add or Remove Programs option, select C1Zip for .NET and click the Remove button.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


End-User License Agreement for ComponentOne Software

End-User License Agreement for ComponentOne Software

IMPORTANT-READ CAREFULLY: This End User License Agreement (this "EULA") contains the terms and conditions regarding your use of the SOFTWARE (as defined below). This EULA contains material limitations to your rights in that regard. You should read this EULA carefully and treat it as valuable property.

I. THIS EULA.

1. Software Covered by this EULA. This EULA governs your use of the ComponentOne, LLC ("C1") software product(s) enclosed or otherwise accompanied herewith (individually and collectively, the "SOFTWARE"). The term "SOFTWARE" includes, to the extent provided by C1: 1) any revisions, updates and/or upgrades thereto; 2) any data, image or executable files, databases, data engines, computer software, or similar items customarily used or distributed with computer software products; 3) anything in any form whatsoever intended to be used with or in conjunction with the SOFTWARE; and 4) any associated media, documentation (including physical, electronic and on-line) and printed materials (the "Documentation").

2. This EULA is a Legally Binding Agreement Between You and C1. If you are acting as an agent of a company or another legal person, such as an officer or other employee acting for your employer, then "you" and "your" mean your principal, the entity or other legal person for whom you are acting. However, importantly, even if you are acting as an agent for another, you may still be personally liable for violation of federal and State laws, such as copyright infringement.

This EULA is a legally binding agreement between you and C1. You intend to be legally bound to this EULA to the same extent as if C1 and you physically signed this EULA. By installing, copying, or otherwise using the SOFTWARE, you agree to be bound by the terms and conditions contained in this EULA. If you do not agree to all of the terms and conditions contained in this EULA, you may not install or use the SOFTWARE. If, for whatever reason, installation has begun or has been completed, you should cancel installation or un-install the SOFTWARE, as the case may be. (You may click on the "exit" button or its equivalent to immediately abort installation.) If you do not agree to all of these terms and conditions, then you must promptly return the SOFTWARE to the place of business from which you obtained it in accordance with any return policies of such place of business. Return policies may vary between or among resellers, and you must comply with your particular reseller's return policies as agreed at the point of purchase. If the place of business from which you purchased the SOFTWARE does not honor a complete refund for a period of thirty (30) days from the date of proof of purchase, then you may return the SOFTWARE directly to C1 for a period of thirty (30) days from the date of your purchase. To return the product directly to C1, you must obtain a C1 Return Authorization Number by contacting C1, and you must forward all items purchased, including the proof of purchase, directly to C1. The return must be postage-prepaid, and post-marked within thirty (30) days from the proof of purchase, time being of the essence. The return option to C1 is only available to the original purchaser of an unopened factory packaged item.

II. YOUR LICENSE TO DEVELOP AND TO DISTRIBUTE.

As provided in more detail below, this EULA grants you two licenses: 1) a license to use the SOFTWARE to develop other software products (the "Development License"); and 2) a license to use and/or distribute the Developed Software (the "Distribution License"). Both of these licenses (individually and collectively, the "Licenses") are explained and defined in more detail below.

1. Definitions. The following terms have the respective meanings as used in this EULA:

"Network Server" means a computer with one or more computer central processing units (CPU's) that operates for the purpose of serving other computers logically or physically connected to it, including, but not limited to, other computers connected to it on an internal network, intranet or the Internet. "Web Server" means a type of Network Server that serves other computers more particularly connected to it over an intranet or the Internet.

"Developed Software" means those computer software products that are developed by or through the use of the SOFTWARE. "Developed Web Server Software" means those Developed Software products that reside logically or physically on at least one Web Server and are operated (meaning the computer software instruction set is carried out) by the Web Server's central processing unit(s) (CPU). "Developed Legacy Software" means those Developed Software products that are not Developed Web Server Software, including, for example, stand-alone applications and applications accessed by a file server only. "Redistributable Files" means the SOFTWARE files or other portions of the SOFTWARE that are provided by C1 and are identified as such in the Documentation for distribution by you with the Developed Software. "Developer" means a human being or any other automated device using the SOFTWARE in accordance with the terms and conditions of this EULA.

"Developer Seat License" means that each Developer using or otherwise accessing the programmatic interface or the SOFTWARE must obtain the right to do so by purchasing a separate End User License.

“Source Code” shall mean computer software code or programs in human readable format, such as a printed listing of such a program written in a high-level computer language. The term "Source Code" includes, but is not limited to, documents and materials in support of the development effort of the SOFTWARE, such as flow charts, pseudo code and program notes.

2. Your Development License. You are hereby granted a limited, royalty-free, non-exclusive right to use the SOFTWARE to design, develop, and test Developed Software, on the express condition that, and only for so long as, you fully comply with all terms and conditions of this EULA.

The SOFTWARE is licensed to you on a Developer Seat License basis.

The Developer Seat License means that you may perform an installation of the SOFTWARE for use in designing, testing and creating Developed Software by a single Developer on one or more computers, each with a single set of input devices, so long as such computer/computers is/are used only by one single Developer at any given time and not concurrently. Conversely, you may not install or use the SOFTWARE on a computer that is a network server or a computer at which the SOFTWARE is used by more than one Developer. You may not network the SOFTWARE or any component part of it, where it is or may be used by more than one Developer unless you purchase an additional Development License for each Developer. You must purchase another separate license to the SOFTWARE in order to add additional developer seats, whether the additional developers are accessing the SOFTWARE in a stand-alone environment or on a computer network.

In all cases, you may not use C1's name, logo, or trademarks to market your Developed Software without the express written consent of C1; (b) you must include the following C1 copyright notice in your Developed Software documentation and/or in the "About Box" of your Developed Software, and wherever the copyright/rights notice is located in the Developed Software (“Portions Copyright © ComponentOne, LLC 1991-2002. All Rights Reserved.”); (c) agree to indemnify, hold harmless, and defend C1, its suppliers and resellers, from and against any claims or lawsuits, including attorney's fees that may arise from the use or distribution of your Developed Software; (d) you may use the SOFTWARE only to create Developed Software that is significantly different than the SOFTWARE.

3. Your Distribution License.

License to Distribute Developed Software. Subject to the terms and conditions in this EULA, you are granted the license to use and to distribute Developed Software on a royalty-free basis, provided that the Developed Software incorporates the SOFTWARE as an integral part of the Developed Software in machine-language compiled format (customarily an ".exe", or ".dll", etc.). You may not distribute, bundle, wrap or subclass the SOFTWARE as Developed Software which, when used in a "designtime" development environment, exposes the programmatic interface of the SOFTWARE. You may distribute, on a royalty-free basis, Redistributable Files with Developed Software only.

4. Specific Product Limitations. Notwithstanding anything in this EULA to the contrary, if the license you have purchased is for any of the following products, then the following additional limitations will apply:

a. ComponentOne Reports for .NET Designer Edition. ComponentOne Reports for .NET Designer Edition includes at least: 1) one dynamic link library (c1.win.c1reportdesigner.dll) file known as C1ReportDesigner Component, 2) one executable (ReportDesigner.exe) file known as C1ReportDesigner Application and, 3) the Source Code of the C1ReportDesigner Application. The C1ReportDesigner Component is subject to the general terms and restrictions set forth in this EULA. The C1ReportDesigner Application is an executable file used to design and prepare reports; the C1ReportDesigner Application may be distributed, free of royalties, only in conjunction with the Developed Software.

Subject to the terms and conditions in this EULA, C1 hereby grants you the right to use the C1ReportDesigner Application Source Code. You are hereby also granted the right to modify such Source Code and to create derivative works that are based on the licensed Source Code. You may distribute the derivative works that you develop, solely in object code format and exclusively in conjunction with and/or as a part of the Developed Software. You are expressly not granted the right to distribute, disclose or otherwise make available to any third party the licensed Source Code, any modified version, derivative work, or any portion thereof, in source code format.

C1 shall retain all right, title and interest in and to the licensed Source Code, and all C1 updates, modifications or enhancements thereof. Nothing herein shall be deemed to transfer any ownership or title rights in and to the licensed Source Code from C1 to you.

SOURCE CODE IS LICENSED TO YOU AS IS. C1 DOES NOT AND SHALL NOT PROVIDE YOU WITH ANY TECHNICAL SUPPORT FOR YOUR SOURCE CODE LICENSE.

b. VSView Reporting Edition. VSView Reporting Edition includes at least one executable file listed as “VSRptX.exe” (where X indicates the version number i.e.7,8, etc.), known as “Designer.” The file "VSRptX.exe”, or any upgrade or future versions of the Designer, are subject to the restrictions set forth in this EULA and may not be distributed with your Developed Software or in any other way.

c. Doc-to-Help and ComponentOne Natural Search. You may use Doc-To-Help to create online help, manuals or other documentation in electronic or printed format (the "Output Documents"). You may distribute and incorporate in such Output Documents those files identified in the documentation as Redistributable Files. Except for those specific Redistributable Files, you MAY NOT distribute the SOFTWARE, in any format, to others.

d. Studio Products. You may not share the component parts of the Studio Products licensed to you with other Developers, nor may you allow the use and/or installation of such components by other Developers.

e. ComponentOne Response and SOAP Channel. ComponentOne Response is intended to be installed on a Network Server. C1 grants to you the following rights to the SOFTWARE: a) Installation: You may install one copy of the SOFTWARE on a single Network Server; b) Use: When installed and initialized, the SOFTWARE creates a database file which contains the embodiment of a solution knowledge base (the database hereinafter referred to as the "Knowledge Base").

You may use the SOFTWARE to create Knowledge Bases on one Network Server only. To create or to operate Knowledge Bases in more than one Network Server, you must purchase one additional SOFTWARE license for each additional Network Server.

5. Updates/Upgrades; Studio Subscription. Subject to the terms and conditions of this EULA, the Licenses are perpetual. Updates and upgrades to the SOFTWARE may be provided by C1 from time-to-time, and, if so provided by C1, are provided upon the terms and conditions offered at that time by C1 in its sole discretion. C1 may provide updates and upgrades to the SOFTWARE for free or for any charge, at any time or never, and through its chosen manner of access and distribution, all in C1's sole and complete discretion.

C1 licenses certain of its separately-licensed products bundled together in a product suite, called the C1 "Studio" product line (the "Studio Products"). The exact separately-licensed products that are bundled into the Studio Products may change from time-to-time in C1's sole discretion. If the SOFTWARE is identified as a C1 "Studio" product, then the SOFTWARE is one of the Studio Products. The SOFTWARE and the Studio Products are revised from time-to-time (meaning, for example, revised with updates, upgrades and, in the case of Studio products, possibly changes to which specific products are included in the bundle). For you to be entitled to receive any such revisions to the SOFTWARE or the Studio Products, as the case may be, you must have a valid SOFTWARE license or a valid Studio subscription. The original purchaser of the SOFTWARE or of a Studio product receives a one-year subscription from the date of purchase of the SOFTWARE. After one year, the Studio subscription and/or the SOFTWARE license must be renewed to continue to be entitled to receive the SOFTWARE and/or the Studio Products revisions as the case may be.

6. Serial Number. Within the packaging of the SOFTWARE, a unique serial number (the "Serial Number") is included, which allows for the registration of the SOFTWARE. The Serial Number is subject to the restrictions set forth in this EULA and may not be disclosed or distributed either with your Developed Software or in any other way. The disclosure or distribution of the Serial Number shall constitute a breach of this EULA, the effect of which shall be the automatic termination and revocation of all the rights granted herein.

7. Evaluation Copy. If you are using an "evaluation copy" or similar version, specifically designated as such by C1 on its website or otherwise, then the Licenses are limited as follows: a) you are granted a license to use the SOFTWARE for a period of thirty (30) days counted from the day of installation (the "Evaluation Period"); b) upon completion of the Evaluation Period, you shall either i) delete the SOFTWARE from the computer containing the installation, or you may ii) contact C1 or one of its authorized dealers to purchase a license of the SOFTWARE, which is subject to the terms and limitations contained herein; and c) any Developed Software may not be distributed or used for any commercial purpose.

III. INTELLECTUAL PROPERTY.

1. Copyright. You agree that all right, title, and interest in and to the SOFTWARE (including, but not limited to, any images, photographs, animations, video, audio, music, text, and “applets” incorporated into the SOFTWARE), and any copies of the SOFTWARE, and any copyrights and other intellectual properties therein or related thereto are owned exclusively by C1, except to the limited extent that C1 may be the rightful license holder of certain third-party technologies incorporated into the SOFTWARE. The SOFTWARE is protected by copyright laws and international treaty provisions. The SOFTWARE is licensed to you, not sold to you. C1 reserves all rights not otherwise expressly and specifically granted to you in this EULA.

2. Backups. You may either: (a) copy the SOFTWARE solely for backup or archival purposes; or (b) install the SOFTWARE on a single computer, provided you keep the original solely for backup or archival purposes. Notwithstanding the foregoing, you may not copy the Documentation.

3. General Limitations. You may not reverse engineer, decompile, or disassemble the SOFTWARE, except and only to the extent that applicable law expressly permits such activity notwithstanding this limitation.

4. Software Transfers. You may not rent or lease the SOFTWARE. You may transfer the SOFTWARE to another computer, provided that it is completely removed from the computer from which it was transferred. You may permanently transfer all of your rights under the EULA, provided that you retain no copies, that you transfer all the SOFTWARE (including all component parts, the media and printed materials, any dates, upgrades, this EULA and, if applicable, the Certificate of Authenticity), and that the recipient agrees to the terms and conditions of this EULA as provided herein. If the SOFTWARE is an update or upgrade, any transfer must include all prior versions of the SOFTWARE.

5. Termination. Without prejudice to any other rights it may have, C1 may terminate this EULA and the Licenses if you fail to comply with the terms and conditions contained herein. In such an event, you must destroy all copies of the SOFTWARE and all of its component parts.

6. Export Restrictions. You acknowledge that the SOFTWARE is of U.S. origin. You acknowledge that the license and distribution of the SOFTWARE is subject to the export control laws and regulations of the United States of America, and any amendments thereof, which restrict exports and re-exports of software, technical data, and direct products of technical data, including services and Developed Software. You agree that you will not export or re-export the SOFTWARE or any Developed Software, or any information, documentation and/or printed materials related thereto, directly or indirectly, without first obtaining permission to do so as required from the United States of America Department of Commerce's Bureau of Export Administration ("BXA"), or other appropriate governmental agencies, to any countries, end-users, or for any end-uses that are restricted by U.S. export laws and regulations, and any amendments thereof, which include, but are not limited to, the following:

Restricted Countries: Restricted Countries currently include, but are not necessarily limited to Cuba, Iran, Iraq, Libya, Montenegro, North Korea, Serbia, Sudan, and Syria.

Restricted End-Users: Any End-User whom you know or have reason to know will use SOFTWARE or Developed Software in the design, development, or production of missiles and missile technology, nuclear weapons and weapons technology, or chemical and biological weapons. Any national of any of the Restricted Countries, wherever located, who intends to transmit or transport the SOFTWARE or Developed Software to one of the Restricted Countries.

Restricted End-Uses: Any use of SOFTWARE and Developed Software related to the design, development, or production of missiles and missile technology, nuclear weapons and weapons technology, or chemical and biological weapons.

These restrictions change from time to time. You represent and warrant that neither the BXA nor any other United States federal agency has suspended, revoked or denied your export privileges. C1 acknowledges that it shall use reasonable efforts to supply you with all reasonably necessary information regarding the SOFTWARE and its business to enable you to fully comply with the provisions of this Section. If you have any questions regarding your obligations under United States of America export regulations, you should contact the Bureau of Export Administration, United States Department of Commerce, Exporter Counseling Division, Washington DC. U.S.A. (202) 482-4811, http://www.bxa.doc.gov.

7. U.S. Government Restricted Rights. The SOFTWARE and documentation are provided with RESTRICTED RIGHTS. For solicitations issued before December 1, 1995, by the United States of America, its agencies and/or instrumentalities (the "Government"), other than the Department of Defense, the use, duplication or disclosure of the software and documentation provided to the Government under this EULA shall be subject to the RESTRICTED RIGHTS as set forth in subparagraphs (c)(1) and (2) of the Commercial Computer Software - Restricted Rights clause at 48 CFR ch.1 52.227-19. For solicitations issued before September 29, 1995, by the Department of Defense, the use, duplication or disclosure of the software and documentation provided under this EULA shall be subject to the RESTRICTED RIGHTS as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at 48 CFR ch.2 252.227-7013. You will comply with any requirements of the Government to obtain such RESTRICTED RIGHTS protection, including without limitation, the placement of any restrictive legends on the SOFTWARE, and any license agreement used in connection with the distribution of the SOFTWARE. Manufacturer is ComponentOne, LLC, 201 South Highland Avenue, 3rd Floor, Pittsburgh, Pennsylvania 15206 USA. For solicitations issued by the Government on or after December 1, 1995 and the Department of Defense on or after September 29, 1995, the only rights provided in the software and documentation provided herein shall be those contained in this EULA. Under no circumstances shall C1 be obligated to comply with any Governmental requirements regarding the submission of or the request for exemption from submission of cost or pricing data or cost accounting requirements. For any distribution of the SOFTWARE that would require compliance by C1 with the Government's requirements relating to cost or pricing data or cost accounting requirements, you must obtain an appropriate waiver or exemption from such requirements for the benefit of C1 from the appropriate Government authority before the distribution and/or license of the SOFTWARE to the Government.

IV. WARRANTIES AND REMEDIES.

1. Limited Warranty. C1 warrants that the original media, if any, are free from defects for ninety (90) days from the date of delivery of the SOFTWARE. EXCEPT AS OTHERWISE PROVIDED IN THE PRECEDING SENTENCE, AND TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, C1 EXPRESSLY DISCLAIMS ANY WARRANTY FOR THE SOFTWARE, DOCUMENTATION AND ANYTHING ELSE PROVIDED BY C1 HEREBY AND C1 PROVIDES THE SAME IN “AS IS” CONDITION WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE AND DOCUMENTATION REMAINS WITH YOU. THIS LIMITED WARRANTY GIVES YOU SPECIFIC LEGAL RIGHTS. YOU MAY HAVE OTHERS WHICH VARY FROM STATE TO STATE.

2. Limited Remedy. C1's entire liability and your exclusive remedy under this EULA shall be, at C1's sole option, either (a) return of the price paid for the SOFTWARE; (b) repair the SOFTWARE through updates distributed online or otherwise in C1's discretion; or (c) replace the SOFTWARE with SOFTWARE that substantially performs as described in the SOFTWARE documentation, provided that you return the SOFTWARE in the same manner as provided in Section I.2 for return of the SOFTWARE for non-acceptance of this EULA. Any media for any repaired or replacement SOFTWARE will be warranted for the remainder of the original warranty period or thirty (30) days, whichever is longer. THESE REMEDIES ARE NOT AVAILABLE OUTSIDE OF THE UNITED STATES OF AMERICA. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL C1 BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFIT, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE, EVEN IF C1 HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME STATES/JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES IN CERTAIN CASES, THE ABOVE LIMITATION MAY NOT APPLY TO YOU.

V. MISCELLANEOUS.

1. This is the Entire Agreement. This EULA (including any addendum or amendment to this EULA included with the SOFTWARE) is the final, complete and exclusive statement of the entire agreement between you and C1 relating to the SOFTWARE. This EULA supersedes any prior and contemporaneous proposals, purchase orders, advertisements, and all other communications in relation to the subject matter of this EULA, whether oral or written. No terms or conditions, other than those contained in this EULA, and no other understanding or agreement which in any way modifies these terms and conditions, shall be binding upon the parties unless entered into in writing executed between the parties, or by other non-oral manner of agreement whereby the parties objectively and definitively act in a manner to be bound (such as by continuing with an installation of the SOFTWARE, "clicking-through" a questionnaire, etc.) Employees, agents and other representatives of C1 are not permitted to orally modify this EULA.

2. You Indemnify C1. You agree to indemnify, hold harmless, and defend C1 and its suppliers and resellers from and against any and all claims or lawsuits, including attorney's fees, which arise out of or result from your breach of any of the terms and conditions of this EULA.

3. Interpretation of this EULA. If for any reason a court of competent jurisdiction finds any provision of this EULA, or any portion thereof, to be unenforceable, that provision of this EULA will be enforced to the maximum extent permissible so as to effect the intent of the parties, and the remainder of this EULA will continue in full force and effect. Formatives of defined terms shall have the same meaning of the defined term. Failure by either party to enforce any provision of this EULA will not be deemed a waiver of future enforcement of that or any other provision. Except as otherwise required or superseded by law, this EULA is governed by the laws of the Commonwealth of Pennsylvania, without regard to its conflict of laws principles. The parties consent to the personal jurisdiction and venue of the Commonwealth of Pennsylvania, in the County of Allegheny, and agree that any legal proceedings arising out of this EULA shall be conducted solely in such Commonwealth. If the SOFTWARE was acquired outside the United States, then local law may apply.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Licensing FAQs

Licensing FAQs

This section describes the main technical aspects of licensing. It may help the user to understand and resolve licensing problems he may experience when using ComponentOne .NET and ASP.NET products.

What is Licensing?

How does Licensing Work?

Common Scenarios

Troubleshooting

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


What is Licensing?

What is Licensing?

Licensing is a mechanism used to protect intellectual property by ensuring that users are authorized to use software products.

Licensing is not only used to prevent illegal distribution of software products. Many software vendors, including ComponentOne, use licensing to allow potential users to test products before they decide to purchase them.

Without licensing, this type of distribution would not be practical for the vendor or convenient for the user. Vendors would either have to distribute evaluation software with limited functionality, or shift the burden of managing software licenses to customers, who could easily forget that the software being used is an evaluation version and has not been purchased.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


How does Licensing Work?

How does Licensing Work?

ComponentOne uses a licensing model based on the standard set by Microsoft, which works with all types of components.

Note: The Compact Framework components use a slightly different mechanism for licensing than the other ComponentOne components due to platform differences.When a user decides to purchase a product, he receives an installation program and a Serial Number. During the installation process, the user is prompted for the serial number that is saved on the system. (Users can also enter the serial number by clicking the "License" button on the About Box of any ComponentOne product.)

When a licensed component is added to a form or web page, Visual Studio asks the newly created component for licensing information. The component looks for licensing information stored in the system and generates a key, which Visual Studio saves in two files:

1. a "<projectName>.licenses" resource file which contains the actual key and

2. a "licenses.licx" file that contains references to those resources.

These files are automatically added to the project.

Note that the licenses.licx file is usually not shown in the Solution Explorer; it appears if you press the "Show All Files" button in the Solution Explorer's toolbox, or select "Project | Show All Files" from Visual Studio's main menu.

Later, when the component is created at run time, it gets passed the key that was created at design time and can decide whether to simply accept the key, to throw an exception and fail altogether, or to display some information reminding the user that the software has not been licensed.

All ComponentOne products are designed to display licensing information if the product is not licensed. None will throw licensing exceptions and prevent applications from running.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Common Scenarios

Common Scenarios

Creating components at design time

Creating components at run time

Inheriting from licensed components

Using licensed components in console applications

Using licensed components in Visual C++ applications

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Creating components at design time

Creating components at design time

This is the most common scenario and also the simplest: the user adds one or more controls to the form, the licensing information is stored in the licenses.licx file, and the component works.

Note that the mechanism is exactly the same for Windows Forms and Web Forms (ASP.NET) projects.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Creating components at run time

Creating components at run time

This is also a fairly common scenario. You do not need an instance of the component on the form, but would like to create one or more instances at run time.

In this case, the project will not contain a licenses.licx file (or the file will not contain an appropriate key for the component) and therefore licensing will fail.

To fix this problem, add an instance of the component to a form in the project. This will create the licenses.licx file and things will then work as expected. (The component can be removed from the form after the licenses.licx file has been created).

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Inheriting from licensed components

Inheriting from licensed components

If a component that inherits from a licensed component is created, the licensing information to be stored in the form is still needed. This can be done in two ways:

Add a LicenseProvider attribute to the component.

This will mark the component as licensed. When a component is added to a form, Visual Studio will create and manage the licenses.licx file, and the base class will handle the licensing process as usual. No additional work is needed. For example:

[LicenseProvider(typeof(LicenseProvider))]

class MyGrid: C1.Win.C1FlexGrid.C1FlexGrid

{

// ...

}

Add an instance of the base component to the form.

This will embed the licensing information into the licenses.licx file as in the previous scenario, and the base component will find it and use it. As before, the extra instance can be deleted after the licenses.licx file has been created.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Using licensed components in console applications

Using licensed components in console applications

When building console applications, there are no forms to add components to, and therefore Visual Studio won't create a licenses.licx file.

In these cases, create a temporary Windows Forms application and add all the desired licensed components to a form. Then close the Windows Forms application and copy the licenses.licx file into the console application project.

Make sure the licensex.licx file is configured as an embedded resource. To do this, right-click the licenses.licx file in the Solution Explorer window and select Properties. In the property window, set the "Build Action" property to "Embedded Resource".

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Using licensed components in Visual C++ applications

Using licensed components in Visual C++ applications

It seems there is a bug in VC++ 2003. The licenses.licx is ignored during the build process, therefore the licensing information is not included in VC++ applications.

To fix this problem, extra steps must be taken to compile the licensing resources and link them to the project. Note the following:

1. Build the C++ project as usual. This should create an exe file and also a licenses.licx file with licensing information in it.

2. Copy the licenses.licx file from the app directory to the target folder (Debug or Release).

3. Copy the C1Lc.exe utility and the licensed dlls to the target folder. (Don't use the standard lc.exe, it has bugs.)

4. Use C1Lc.exe to compile the licenses.licx file. The command line should look like this:

c1lc /target:MyApp.exe /complist:licenses.licx /i:C1.Win.C1FlexGrid.dll

5. Link the licenses into the project. To do this, go back to Visual Studio, right-click the project, select properties, and go to the Linker/Command Line option. Enter the following:

/ASSEMBLYRESOURCE:Debug\MyApp.exe.licenses

6. Rebuild the executable to include the licensing information in the application.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Troubleshooting

Troubleshooting

We try very hard to make the licensing mechanism as unobtrusive as possible, but problems may occur for a number of reasons.

Below is a description of the most common problems and their solutions.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


I have a licensed version of a ComponentOne product but I still get the splash screen when I run my project.

I have a licensed version of a ComponentOne product but I still get the splash screen when I run my project.

If this happens, there must be a problem with the licenses.licx file in the project. It either doesn't exist, contains wrong information, or is not configured correctly.

First, try a full rebuild ("Rebuild All" from the Visual Studio Build menu). This will usually rebuild the correct licensing resources.

If that fails, follow these steps:

1. Open the project and go to the Solution Explorer window.

2. Click the "Show All Files" button on the top of the window.

3. Find the licenses.licx file and delete it.

4. Close the project and reopen it.

5. Open the main form and add an instance of each licensed control.

6. Check the Solution Explorer window, there should be a licenses.licx file there.

7. Rebuild the project using the "Rebuild All" option (not just "Rebuild").

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


I have a licensed version of a ComponentOne product on my web server but the components still behave as unlicensed.

I have a licensed version of a ComponentOne product on my web server but the components still behave as unlicensed.

There is no need to install any licenses on machines used as servers and not used for development.

The components must be licensed on the development machine, therefore the licensing information will be saved into the executable (exe or dll) when the project is built. After that, the application can be deployed on any machine, including web servers.

Note that additional server licenses may be needed to be able to _legally_ deploy applications on web servers. Please refer to the EULA or contact sales@componentone.com for details.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


I downloaded a new build of a component that I have purchased, and now I'm getting the splash screen when I build my projects.

I downloaded a new build of a component that I have purchased, and now I'm getting the splash screen when I build my projects.

Make sure that the license key is still valid. If you licensed the component over a year ago, your subscription may have expired. In this case, you have two options:

Option 1 - Renew your subscription to get a new license key.

If you choose this option, you will receive a new key that you can use to license the new components (from the installation utility or directly from the About Box).

The new subscription will entitle you to a full year of upgrades and to download the latest maintenance builds directly from http://prerelease.componentone.com/.

Option 2 – Continue to use the components you have.

Subscriptions expire, products do not. You can continue to use the components you received or downloaded while your subscription was valid.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Technical Support

Technical Support

Zip for .NET is developed and supported by ComponentOne LLC, a company formed by the merger of APEX Software Corporation and VideoSoft. You can obtain technical support using any of the following methods:

ComponentOne Web site

ComponentOne HelpCentral

Internet e-mail

Peer-to-Peer newsgroup

Documentation

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ComponentOne Web site

ComponentOne Web site

The ComponentOne Web site at http://www.componentone.com/ provides a wealth of information and software downloads for Zip for .NET users, including:

· Descriptions of the various support options available through the ComponentOne Service Team.

· Answers to frequently asked questions (FAQ's) about our products, organized by functionality. Please consult the FAQ's before contacting us directly, as this can save you time and also introduce you to other useful information pertaining to our products.

· Free product updates, which provide you with bug fixes and new features.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ComponentOne HelpCentral

ComponentOne HelpCentral

ComponentOne HelpCentral is the new online resource for Visual Studio developers and Help authors. Visit HelpCentral to get information on ComponentOne products, view online demos, get Tech Tips and answers to frequently asked questions (FAQ's), search the ComponentOne knowledgebase and more!

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Internet e-mail

Internet e-mail

For technical support through the Internet, e-mail us at:

support.c1zip@componentone.com

To help us provide you with the best support, please include the following information when contacting ComponentOne:

· Your ComponentOne product serial number.

· The version and name of your operating system.

· Your development environment and its version.

For more information on technical support, go to:

http://www.componentone.com/support

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Peer-to-Peer newsgroup

Peer-to-Peer newsgroup

ComponentOne also sponsors peer-to-peer newsgroups for users. ComponentOne does not offer formal technical support in this newsgroup, but instead sponsors it as a forum for users to post and answer each other's questions regarding our products. However, ComponentOne may monitor the newsgroups to ensure accuracy of information and provide comments when necessary. You can access the newsgroup from the ComponentOne Web site at http://helpcentral.componentone.com/Newsgroups.aspx.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Documentation

Documentation

ComponentOne documentation is available with each of our products in HTML Help, Microsoft Help 2.0 (.NET, ASP.NET and Mobile Device products only), and PDF format. All of the PDFs are also available on our Web site. If you have suggestions on how we can improve our documentation, please email the Documentation team. Please note that e-mail sent to the Documentation team is for documentation feedback only. Technical Support and Sales issues should be sent directly to their respective departments.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Redistributable Files

Redistributable Files

ComponentOne Zip for .NET is developed and published by ComponentOne LLC. You may use it to develop applications in conjunction with Microsoft Visual Studio or any other programming environment that enables the user to use and integrate the control(s). You may also distribute, free of royalties, the following Redistributable Files with any such application you develop to the extent that they are used separately on a single CPU on the client/workstation side of the network:

· C1.C1Zip.dll

Note: A distribution license must be obtained for each server CPU on which your Developed Web Server Application is installed. If your Developed Web Server Application is installed on a server for which a license has already been purchased, and only one CPU is operating the application, it is not necessary to purchase an additional license. However, additional licenses must be purchased for each additional CPU on the network that is operating the Developed Web Server Application.

For a more detailed account of your rights to distribute your Developed Web Server Software, please see the End-User License Agreement for ComponentOne Software.

Site licenses are available for groups of multiple developers. Please contact Sales@ComponentOne.com for details.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Namespaces

Namespaces

Namespaces organize the objects defined in an assembly. Assemblies can contain multiple namespaces, which can in turn contain other namespaces. Namespaces prevent ambiguity and simplify references when using large groups of objects such as class libraries.

The namespace for the C1Zip component is C1.C1Zip. The following code fragment shows how to declare a C1Zip component using the fully qualified name for this class:

· Visual Basic

· C#

· Delphi

Namespaces address a problem sometimes known as namespace pollution, in which the developer of a class library is hampered by the use of similar names in another library. These conflicts with existing components are sometimes called name collisions.

For example, if you create a new class named C1ZipFile, you can use it inside your project without qualification. However, the C1Zip assembly also implements a class called C1ZipFile. So, if you want to use the C1Zip class in the same project, you must use a fully qualified reference to make the reference unique. If the reference is not unique, Visual Studio .NET produces an error stating that the name is ambiguous. The following code snippet demonstrates how to declare these objects:

· Visual Basic

· C#

· Delphi

Fully qualified names are object references that are prefixed with the name of the namespace where the object is defined. You can use objects defined in other projects if you create a reference to the class (by choosing Add Reference from the Project menu) and then use the fully qualified name for the object in your code.

Fully qualified names prevent naming conflicts because the compiler can always determine which object is being used. However, the names themselves can get long and cumbersome. To get around this, you can use the Imports statement (using in C#) to define an alias — an abbreviated name you can use in place of a fully qualified name. For example, the following code snippet creates aliases for two fully qualified names, and uses these aliases to define two objects:

· Visual Basic

· C#

· Delphi

If you use the Imports statement without an alias, you can use all the names in that namespace without qualification, provided they are unique to the project.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Creating a .NET Project

Creating a .NET Project

This topic demonstrates how to create a new .NET project.

1. From the File menu in Microsoft Visual Studio .NET, select New and click Project. The New Project dialog box opens.

2. Under Project Types, choose either Visual Basic Projects or Visual C# Projects, and select Windows Application from the list of Templates in the right pane.

Enter a name for your new application in the Name field or you can use the default name, WindowsApplication1. Click on the Browse button to the right of the Location field to specify the location of your new project and click OK.

A new Microsoft Visual Studio .NET project is created in the specified location. In addition, a new Form1 is displayed in the Designer view.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Adding a Reference to the C1Zip Assembly

Adding a Reference to the C1Zip Assembly

When you install C1Zip, a new component does not appear in the Visual Studio’s toolbox. Therefore, to use C1Zip, you must reference the C1Zip assembly in your project. To use the C1Zip component:

1. Select the Add Reference option from the Project menu of your project.

2. The Add Reference dialog box appears. Select the C1.C1Zip assembly from the list, or browse to find the C1.C1Zip.dll file. Double-click the component and select OK.

Note: In Visual Studio 2003 you would select the ComponentOne C1Zip from the list.

3. In the Solution Explorer, notice C1Zip has been referenced to your project.

4. Select the Form1.vb tab or go to View|Code to open the code window. At the top of the file, add the following Imports statements (using in C#):

· Visual Basic

· C#

· Delphi

Note: This makes the objects defined in the C1Zip and System.IO assemblies visible to the project and saves a lot of typing.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Using C1Zip

Using C1Zip

The following sections contain tutorials that illustrate some of the main features in the C1Zip library. The tutorials walk you through the creation of several simple projects, describing each step in detail. The distribution CD contains more sophisticated samples that can be used as a reference.

The tutorials are:

Compressing Data in Memory | Shows how you can compress and expand arbitrary data in memory. This technique is useful in any situation where you keep memory streams while the application is running. By compressing the streams, you can reduce the memory requirements for your application.
Compressing Files | Shows how you can compress individual files so they take up less disk space and are less exposed to access by users. Note that these are not Zip files, just individual compressed files. The last tutorial covers Zip files.
Compressed Serialization | Shows how you can combine C1Zip with .NET serialization to save objects into streams that are a fraction of the regular size. If you are serializing objects into XML streams, the savings in disk space and network bandwidth can be huge.
Handling Zip Files | Shows how you can open, inspect, add, and remove files in a Zip archive. Using the Zip format for your application storage needs has several advantages: it is an open-standard, well-documented, space-efficient format.

Compressing Data in Memory

Compressing Files

Compressed Serialization

Handling Zip Files

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Compressing Data in Memory

Compressing Data in Memory

This tutorial shows how you can compress basic data types such as strings and doubles into memory streams, and expand the data back when you read it from the streams.

Here is what the final application will look like:

Step 1: Create the main form.

Start a new Visual Basic project, see Creating a .NET Project. Then from the toolbox, add the following controls to the form, see by dragging and dropping them onto the form or by double-clicking the component:

1. Four Button controls along the left edge of the form, as shown in the picture above. Select each button, and under Font in the Properties window change the Text property of each button to "Compress String", "Decompress String", "Compress Data", and "Decompress Data". Next, change the Name of each button to "btnCompressString", "btnExapndString", "btnCompressData", and "btnExpandData", respectively.

2. Under Behavior in the Properties window, set the Enabled property of the two "Decompress" buttons to False (they cannot be used until we have some compressed data to expand).

3. A TextBox on the upper-right of the form. Under Behavior in the Properties window , set the MultiLine property to True.Select the Ellipsis button next to Lines property. In the String Collection Editor dialog box type text to use as an initial value.

4. A Label control below the text box.

Step 2: Add a reference to the C1Zip assembly.

Go to the Solution Explorer window, right-click on References, and select the Add Reference… menu option. Select the C1.C1Zip assembly from the list, or browse to find the C1.C1Zip.dll file.

Note: In Visual Studio 2003 you would select the ComponentOne C1Zip from the list.

Select the Form1.vb tab or go to View|Code to open the code window. At the top of the file, add the following statements:

· Visual Basic

· C#

· Delphi

This makes the objects defined in the C1Zip assembly visible to the project and saves a lot of typing.

See also, Adding a Reference to the C1Zip Assembly.

Step 3: Add code to compress strings.

Open the code window, then type (or copy) the following code to handle the click event for the "Compress String" command button:

· Visual Basic

· C#

· Delphi

The main lines are the ones marked in boldface. The first one declares a member variable called m_CompressedString which will be used to hold the compressed data (encoded as a byte array). The second calls a utility function CompressString that compresses a given string into a byte array that can later be expanded to restore the original string. The remainder of the code is used to measure how long the compression process took and to show a dialog box with statistics.

(Note that the lenBefore variable is calculated as the length of the string times two. This is because .NET strings are Unicode, and each character actually takes up two bytes.)

Here is the code that implements the CompressString function:

· Visual Basic

· C#

· Delphi

The function starts by creating a new memory stream. This stream will automatically allocate a memory buffer to hold the compressed data.

Next, the function creates a C1ZStreamWriter object and attaches it to the new memory stream. Any data written to the C1ZStreamWriter object will be compressed and written to the memory stream.

The C1ZStreamWriter object only supplies the basic Stream methods for writing bytes and byte arrays. To be able to write other basic types such as strings, integers, etc., we attach a StreamWriter object to the C1ZStreamWriter. Here's a diagram that shows how this works:

After the StreamWriter is set up, all we need to do is call its Write method to write the string into the compressed memory stream. When done writing, we also call the Flush method to make sure all cached input is written out.

Finally, the code uses the ToArray method to return the byte array that was created by the memory stream.

Step 4: Add code to expand strings.

To expand the string, we need to follow the reverse sequence of steps used to compress. Open the code window, then type or copy the following code to handle the click event for the "Decompress String" command button:

· Visual Basic

· C#

· Delphi

The main line is the one in bold. It calls the utility function ExpandString that takes a byte array and returns the original string. Here's the code:

· Visual Basic

· C#

· Delphi

If you run the project now, you can already experiment with string compression and decompression. You can change the text in the text box, or paste new content into it, then compress and expand the string to see how much it compresses.

Step 5: Add code to compress binary data.

Compressing binary data is just as easy as compressing strings. The only difference is that instead of attaching a StreamWriter object to the compressor stream, you attach a BinaryWriter object.

In the code window, add the following code to handle the click event for the "Compress Data" command button:

· Visual Basic

· C#

· Delphi

The code starts by declaring a member variable called m_CompressedData which will be used to hold the compressed data (encoded as a byte array).

Then it sets up the MemoryStream, C1ZStreamWriter, and BinaryWriter objects as before (the only difference is we're now using a BinaryWriter instead of a StreamWriter).

Next, the code writes data into the stream using the Write method. The BinaryWriter object overloads this method so you can write all basic object types into streams. Finally, the Flush method is used as before, to make sure any cached data is written out to the compressed stream.

Step 6: Add code to expand the binary data.

Expanding the compressed binary data is just a matter of setting up the decompressor stream and reading the data like you would read it from a regular stream.

In the code window, add the following event handler code for the "Decompress Data" command button:

· Visual Basic

· C#

· Delphi

The code reads the data but does not display it. You can step through it in debug mode to make sure the data being read is the same that was written in.

If you run the project and click the compress/decompress data buttons, you will see that the data is saved in an array with 14,125 bytes. To save this data in a regular stream, it would take [4 + 1000 * (4 + 8 * 3)] = 28,004 bytes. So we compressed it to about half the original size.

This is the end of this tutorial.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Compressing Files

Compressing Files

This tutorial shows how you can compress and expand individual files. Note that these are not zip files; they are just compressed streams on disk. Zip files are covered in the Handling Zip Files tutorial.

Here is what the final application will look like:

Step 1: Create the main form.

Start a new Visual Basic project and from the Toolbox, add the following controls to the form:

1. Two Button controls along the left edge of the form, as shown in the picture above. Select each button, and in the Properties window set the Text property of each button to "Compress Files" and "Expand Files". Next, change the Name of each button to "btnCompress"and "btnExpand", respectively. Set the Enabled property of the "Expand Files" button to False (it cannot be used until we have some compressed files to expand).

2. A Label control on the right of the buttons. This control will display statistics about the compression/expanding process.

Step 2: Add a reference to the C1Zip assembly.

Go to the Solution Explorer window, right-click on References, and select the Add Reference… menu option. Select the C1.C1Zip assembly from the list, or browse to find the C1.C1Zip.dll file.

Note: In Visual Studio 2003 you would select the ComponentOne C1Zip from the list.

Select the Form1.vb tab or go to View|Code to open the code window. At the top of the file, add the following statements:

· Visual Basic

· C#

· Delphi

This makes the objects defined in the C1Zip and System.IO assemblies visible to the project and saves a lot of typing.

See also, Adding a Reference to the C1Zip Assembly.

Step 3: Define the directory names for the compressed and expanded files.

In the code window of the form, define the following constants:

· Visual Basic

· C#

· Delphi

These are the directory names where the compressed and expanded files will be stored (relative to the directory where the tutorial application is located on your disk).

Step 4: Add code to compress files.

In the code window, type (or copy) the following code to handle the click event for the "Compress Files" command button:

· Visual Basic

· C#

· Delphi

The main line is marked in boldface. It calls the utility function CompressFile utility method to compress each selected file. The compressed files are stored in the \compressed directory under the application folder. They have the same name as the original file, plus a "cmp" extension.

Here’s the code for the CompressFile function:

· Visual Basic

· C#

· Delphi

The function starts by creating two new file streams: one for the source file and one for the compressed file. Then it creates a C1ZStreamWriter object and attaches it to the destination stream. Next, it calls the StreamCopy function to transfer data from the source file and write it into the compressor stream.

Finally, the function closes both streams. Note the use of the Finally statement to ensure that both streams are properly closed even if there are exceptions while the function is executing.

The StreamCopy function simply copies bytes from one stream to another. Here’s the code:

· Visual Basic

· C#

· Delphi

Note that the function calls the Flush method after it is done to ensure that any cached data is written out when the function is done copying. This is especially important when dealing with compressed streams, since they cache substantial amounts of data in order to achieve good compression rates.

Step 5: Add code to expand files.

In the code window, type (or copy) the following code to handle the click event for the "Expand Files" command button:

· Visual Basic

· C#

· Delphi

The main line is marked in boldface. It calls the utility function ExpandFile utility method to expand the files that were compressed earlier. The expanded files are stored in the \expanded directory under the application folder. They have the same name as the original file, minus the "cmp" extension.

Here’s the code for the ExpandFile function:

· Visual Basic

· C#

· Delphi

The function is similar to CompressFile, except it attaches a C1ZStreamReader to the source stream instead of attaching a C1ZStreamWriter to the destination stream.

This is the end of this tutorial.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Compressed Serialization

Compressed Serialization

This tutorial shows how you can serialize objects in compressed files, and then load them back into the memory.

The sample creates a data table using the NorthWind database. The table is saved (serialized) into regular and compressed streams. Finally, the data is loaded back from either stream.

Here is what the final application will look like:

Step 1: Create the main form.

Start a new Visual Basic project and from the Toolbox, add the following controls to the form:

1. Four Button controls along the left edge of the form, as shown in the picture above. Select each button, and in the Properties window set the Text property of each button to "Create Data Sample", "Save Data Sample", "Load Data Table", and "Load Compressed Data Table". Next, change the Name of each button to "btnCreate", "btnSave", "btnLoad", and "btnLoadCompressed", respectively. Set the Enabled property of the save and load buttons to False (they cannot be used until the data table has been created or saved).

2. A DataGrid control on the right of the form.

3. A StatusBar control docked at the bottom of the form.

Step 2: Add references and Imports statements.

Go to the Solution Explorer window, right-click on References, and select the Add Reference… menu option. Select the C1.C1Zip assembly from the list, or browse to find the C1.C1Zip.dll file.

Note: In Visual Studio 2003 you would select the ComponentOne C1Zip from the list.

Select the Form1.vb tab or go to View|Code to open the code window. At the top of the file, add the following statements:

· Visual Basic

· C#

· Delphi

This declares the namespaces of the classes used in the project.

See also, Adding a Reference to the C1Zip Assembly.

Step 3: Declare constants.

In the code window of the form, type or copy the following lines in the body of the form implementation.

· Visual Basic

· C#

· Delphi

These constants define the name of the database used to populate the data table and the file names used to serialize the data.

Step 4: Add code to create the data table.

In the code window of the form, type (or copy) the following code to handle the click event for the "Create Data Table" button:

· Visual Basic

· C#

· Delphi

The function uses standard ADO.NET objects and methods to create and populate a DataTable object, which is then bound to the DataGrid control.

Step 5: Add code to save the data table.

In the code window, type (or copy) the following code to handle the click event for the "Save Data Table" button:

· Visual Basic

· C#

· Delphi

The main lines are the ones in boldface. The first set serializes the DataTable into a regular file; the second into a compressed file. Note that only one additional line is required to compress the data.

In both cases, the serialization is executed by the BinaryFormatter object. The only difference is that in the first case, the Serialize method is called with a regular file stream as a parameter; in the second, a C1ZStreamWriter is used instead.

Step 6: Add code to load the data table from the regular file.

In the code window, type (or copy) the following code to handle the click event for the "Load Data Table" button:

· Visual Basic

· C#

· Delphi

The main lines are in boldface. The first one creates a new BinaryFormatter object and the second one calls its Deserialize method. The Deserialize method takes a single parameter: the stream in which the object is defined. In this case, the stream is a regular file stream.

Step 7: Add code to load the data table from the compressed file.

In the code window, type (or copy) the following code to handle the click event for the "Load Compressed Data Table" button:

· Visual Basic

· C#

· Delphi

The main lines are marked in boldface. They are similar to the code used to deserialize data from a regular file. The only difference is that instead of passing a regular file stream to the Deserialize method, we now use a C1ZStreamReader object.

This is the end of the Compressed Serialization Tutorial.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Handling Zip Files

Handling Zip Files

This tutorial shows how you can handle zip files, including:

1. Opening an existing Zip file,

2. Testing the integrity of a zip file,

3. Expanding entries into memory streams,

4. Adding entries to the zip file,

5. Extracting entries from the zip file, and

6. Removing entries from the zip file.

Here is what the final application will look like:

Note: This is a very simple application, designed to highlight the main functionality of the C1ZipFile object. The distribution disk also includes a more sophisticated version, written in C#, that supports more advanced features such as drag and drop, zipping folders, setting the compression level, etc.

Step 1: Create the main form.

Start a new Visual Basic project and from the Toolobox, add the following controls to the form:

1. Six Button controls along the left edge of the form, as shown in the picture above. Select each button, and in the Properties window set the Text property of each button to "Open Zip File…", "Test Zip File", "View File", "Add Files…", "Extract Files", and "Remove Files". Next, change the Name of each button to "btnOpen", "btnTest", "btnView", "btnAdd", "btnExtract", and "btnRemove", respectively.

2. A ListView control covering the right part of the form. In the Properties window, click on the Ellipsis button next to the Columns property to bring up the ColumnHeader Collection Editor. Click the Add button to add five ColumnHeaders, and then set the Text property of each column to "File", "Date", "Size", "Compressed", and "Amount", respectively.

Here is what the ColumnHeader Collection Editor should look like:

Select OK to close the editor box. Note that to view the column headers, in the Properties Window set the View property to Details.

Step 2: Add a reference to the C1Zip assembly.

Go to the Solution Explorer window, right-click on References, and select the Add Reference… menu option. Select the C1.C1Zip assembly from the list, or browse to find the C1.C1Zip.dll file.

Note: In Visual Studio 2003 you would select the ComponentOne C1Zip from the list.

Select the Form1.vb tab or go to View|Code to open the code window. At the top of the file, add the following statements:

· Visual Basic

· C#

· Delphi

This makes the objects defined in the C1Zip and System.IO assemblies visible to the project.

See also, Adding a Reference to the C1Zip Assembly.

Step 3: Declare a C1ZipFile object.

Switch to the code window and type (or copy) the following data member declaration:

· Visual Basic

· C#

· Delphi

This is the main object in this application. It implements the methods used to handle Zip files.

Step 4: Add code to initialize the C1ZipFile object.

Go to the code window to add code to the Load event of the form. Type or copy the following code:

· Visual Basic

· C#

· Delphi

This code creates a new C1ZipFile object and assigns it to the m_Zip member. Note that the C1ZipFile object cannot be used yet. It needs to be attached to an existing zip file first using the Open method (or to a new one using the Create method).

Step 5: Add code to open a Zip file.

In the code window, type (or copy) the following code to handle the click event for the "Open Zip File…" command button:

· Visual Basic

· C#

· Delphi

The main line is the one marked in boldface. It calls the Open method on the C1ZipFile object to attach the object to an existing zip file. Note the use of a Try/Catch statement, mainly to handle situations where the user selects a file that is not a zip file.

After opening the file, the code calls the UpdateDisplay utility function to display the contents of the zip file.

Step 6: Add code to update the display.

Next, add the UpdateDisplay utility function to display the contents of the zip file:

· Visual Basic

· C#

· Delphi

The main lines are marked in boldface. They start by declaring a C1ZipEntry object and using it in a ForEach loop over the entries in the zip file (m_Zip.Entries).

For each entry, the function creates a ListViewItem containing the information extracted from the C1ZipEntry object and adds the new entry to the ListView control. Note that the C1ZipEntry object itself is also saved in the Tag property of the ListView items.

Finally, the code enables or disables the command buttons depending on whether or not there are entries available to be extracted, removed or tested.

Step 7: Add code to test the integrity the Zip file.

Open the code window if it is not already opened, and type (or copy) the following code to handle the click event for the "Test Zip File" command button:

· Visual Basic

· C#

· Delphi

The main lines are marked in boldface. They declare a C1ZipEntry variable and use it to loop over the entries in the zip file. The routine then calls the CheckCRC32 method on each entry to check whether the actual checksum of the bytes stored in the file matches the checksum stored in the entry header. The function returns true if the values match and false if they don't (which indicates the entry is corrupted).

Step 8: Add code to view the contents of an entry.

In the code window, type (or copy) the following code to handle the click event for the "View File" command button:

· Visual Basic

· C#

· Delphi

The function starts by choosing the first selected zip entry that is not a subdirectory. If a valid entry cannot be found, the function exits.

The function then calls the OpenReader method to obtain a Stream that can be used to read the contents of the entry. There are no temporary files or additional delays involved in this step, the data is expanded as it is read from the stream.

Next, the function reads the entry content directly into a string using the ReadToEnd method on the StreamReader object, then closes the stream.

Finally, the string is truncated and displayed in a MessageBox.

Note that this function was designed to show the contents of short text files. If you try to view the contents of binary files, it will show only a couple of characters.

Step 9: Add code to add entries to the Zip file.

Open the code window, then type (or copy) the following code to handle the click event for the "Add Files" command button:

· Visual Basic

· C#

· Delphi

Adding new entries to a Zip file is easy. The line in boldface simply calls the Add method on the C1ZipFile object, passing a string that contains the full name of the file to be added. That’s all there is to it.

Step 10: Add code to extract a Zip entry.

In the code window, type (or copy) the following code to handle the click event for the "Extract Files" command button:

· Visual Basic

· C#

· Delphi

The most important line is marked in boldface. It calls the Extract method on the Entries property of the C1ZipFile object. The parameter is the string that contains the file name of the entry (which is stored in the entry’s FileName property).

By default, the Extract method expands the entry and saves it in the same directory where the zip file is located. There are other versions of this method that allow you to specify the destination directory and file name for the expanded file. For more details, see the C1.C1Zip.Namespace section.

Step 11: Add code to remove entries from the Zip file.

In the code window, type (or copy) the following code to handle the click event for the "Remove Files" command button:

· Visual Basic

· C#

· Delphi

The most important line is marked in boldface. It calls the Remove method on the Entries property of the C1ZipFile object. The parameter is the string that contains the file name of the entry (which is stored in the entry’s FileName property).

This is the end of this tutorial.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1Zip for .NET Samples

C1Zip for .NET Samples

Please be advised that this ComponentOne software title is accompanied by various sample projects and/or demos, which may or not make use of other ComponentOne development tools. While the sample projects and/or demos included with the software are used to demonstrate and highlight the product’s features, and how the control may be integrated with the rest of the ComponentOne product line, some of the controls used in the demo/sample project may not be included with the purchase of certain individual products.

The ComponentOne Samples are also available at http://helpcentral.componentone.com/ProductResources.aspx.

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C# Samples

C# Samples

Files | Shows how to compress and expand individual files. This sample calls the C1.C1Zip namespace.
Memory | Shows how to compress and expand memory streams. This sample calls the C1.C1Zip namespace.
Self-Extract (C# only) | Self-extracting application. This sample calls the C1.C1Zip namespace.
Serialization | Shows how to add compression to the .NET serialization support. This sample calls the C1.C1Zip namespace.
ZipFileDemo | Shows how to implement a simple Zip utility. This sample uses the C1.C1Zip namespace.
Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ComponentOne Zip for Mobile Devices Samples

ComponentOne Zip for Mobile Devices Samples

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Visual Basic and C# Samples

Visual Basic and C# Samples

DataSet | Add compression to the .NET serialization support. This sample calls the C1.C1Zip namespace.
LongString | Compress and expand strings. This sample calls the C1.C1Zip namespace.
ZipFile | Implement a simple Zip utility. This sample calls the C1.C1Zip namespace.
Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1Zip Frequently Asked Questions

C1Zip Frequently Asked Questions

Below are some frequently asked questions (FAQs) about C1Zip:

How much data can be stored in a ZIP file comment? I would like to use it to store information in XML.

They are limited to 32k. However, if you are going anywhere near that value, it would be better to add that information as a separate file instead.

What is the maximum number of files that can be stored in a ZIP file?

Same limit, 32k entries. The total length of the zip file is limited to 4 gigs. All these limits are related to the types of variables used in the zip file specification. Interestingly, there's a proposed spec for 64-bit extensions to the zip format, but that's not widely used yet, and there is a lot of debate still going on.

I am currently creating a zip file which contains multiple XML files. If I do not wish to create the individual XML files on a disk, can I stream multiple XML files directly into the zip file?

You can do this using the C1ZipEntryCollection.OpenWriter Method . That returns a stream that you can write to, and when the stream is closed it is added to the zip file.

For example:

· Visual Basic

· C#

· Delphi

To read an entry without saving it to a file, use the C1ZipEntry.OpenReader Method on the entry object. (Note that OpenWriter is a member of the ZipEntryCollection class, while OpenReader is a member of the ZipEntry class.)

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1.C1Zip Assembly

C1.C1Zip Assembly

Namespaces

C1.C1Zip

C1.C1Zip.ZLib

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1.C1Zip Namespace

C1.C1Zip Namespace

C1.C1Zip Hierarchy

Classes

Class | Description
C1ZipEntry | Represents an entry in a zip file, and exposes information including the entry name, compressed and uncompressed sizes, date, checksum, etc.
C1ZipEntryCollection | A collection of C1ZipEntry objects that represent the contents of a zip file.
C1ZipFile | Used for creating, opening, and managing zip files.
C1ZStreamReader | Decompresses data from .NET streams.
C1ZStreamWriter | Compresses data into .NET Streams.
ZipProgressEventArgs | Provides data for the C1.C1Zip.C1ZipFile.Progress event of a C1ZipFile.

Delegates

Delegate | Description
ZipProgressEventHandler | Represents the method that will handle the C1.C1Zip.C1ZipFile.Progress event of a C1ZipFile.

Enumerations

Enumeration | Description
CompressionLevelEnum | Specifies the level of compression to be applied when adding entries to a C1ZipFile.

See Also

C1.C1Zip Assembly

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntry Class

C1ZipEntry Class

Represents an entry in a zip file, and exposes information including the entry name, compressed and uncompressed sizes, date, checksum, etc.

For a list of all members of this type, see C1ZipEntry Members.

System.Object

C1.C1Zip.C1ZipEntry

[Visual Basic]

Public Class C1ZipEntry

[C#]

public class C1ZipEntry

[Delphi]

type C1ZipEntry = class;

Namespace: C1.C1Zip

Assembly: C1.C1Zip (in c1.c1zip.dll)

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntry Members

C1ZipEntry Members

C1ZipEntry overview

Public Properties

Attributes | Gets the file attributes associated with the entry.
Comment | Gets or sets a comment associated with the entry.
CRC32 | Gets the checksum calculated when the entry was compressed.
Date | Gets the date and time when the file used to create the entry was last modified.
FileName | Gets the entry name. This is usually a file name, optionally including a path.
IsEncrypted | Gets a value that determines whether the entry is encrypted.
SizeCompressed | Gets the compressed size of the entry, in bytes.
SizeUncompressed | Gets the original (uncompressed) size of the entry, in bytes.

Public Methods

CheckCRC32 | Calculates a checksum value for the entry and compares it to the checksum that was stored when the entry was created.
OpenReader | Returns a Stream that can be used to read the content of the entry without extracting it to a disk file.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntry Properties

C1ZipEntry Properties

The properties of the C1ZipEntry class are listed here. For a complete list of C1ZipEntry class members, see the C1ZipEntry Members topic.

Public Properties

Attributes | Gets the file attributes associated with the entry.
Comment | Gets or sets a comment associated with the entry.
CRC32 | Gets the checksum calculated when the entry was compressed.
Date | Gets the date and time when the file used to create the entry was last modified.
FileName | Gets the entry name. This is usually a file name, optionally including a path.
IsEncrypted | Gets a value that determines whether the entry is encrypted.
SizeCompressed | Gets the compressed size of the entry, in bytes.
SizeUncompressed | Gets the original (uncompressed) size of the entry, in bytes.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntry.Attributes Property

C1ZipEntry.Attributes Property

Gets the file attributes associated with the entry.

[Visual Basic]

Public ReadOnly Property Attributes As FileAttributes

[C#]

public FileAttributes Attributes {get;}

[Delphi]

public property Attributes: FileAttributes read get_Attributes;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntry.Comment Property

C1ZipEntry.Comment Property

Gets or sets a comment associated with the entry.

[Visual Basic]

Public Property Comment As String

[C#]

public string Comment {get;set;}

[Delphi]

public property Comment: String read get_Comment write set_Comment;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntry.CRC32 Property

C1ZipEntry.CRC32 Property

Gets the checksum calculated when the entry was compressed.

[Visual Basic]

Public ReadOnly Property CRC32 As Integer

[C#]

public int CRC32 {get;}

[Delphi]

public property CRC32: Int32 read get_CRC32;

Remarks

This value can be used to check the integrity of the entry when it is decompressed.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntry.Date Property

C1ZipEntry.Date Property

Gets the date and time when the file used to create the entry was last modified.

[Visual Basic]

Public ReadOnly Property Date As Date

[C#]

public DateTime Date {get;}

[Delphi]

public property Date: DateTime read get_Date;

Remarks

This value can be used to check whether an entry needs to be updated because the source file was modified since it was last compressed.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntry.FileName Property

C1ZipEntry.FileName Property

Gets the entry name. This is usually a file name, optionally including a path.

[Visual Basic]

Public ReadOnly Property FileName As String

[C#]

public string FileName {get;}

[Delphi]

public property FileName: String read get_FileName;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntry.IsEncrypted Property

C1ZipEntry.IsEncrypted Property

Gets a value that determines whether the entry is encrypted.

[Visual Basic]

Public ReadOnly Property IsEncrypted As Boolean

[C#]

public bool IsEncrypted {get;}

[Delphi]

public property IsEncrypted: Boolean read get_IsEncrypted;

Remarks

Encrypted entries can only be extracted if the Password property on the containing C1ZipFile object is set to the password that was used when the file was added to the zip file.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntry.SizeCompressed Property

C1ZipEntry.SizeCompressed Property

Gets the compressed size of the entry, in bytes.

[Visual Basic]

Public ReadOnly Property SizeCompressed As Integer

[C#]

public int SizeCompressed {get;}

[Delphi]

public property SizeCompressed: Int32 read get_SizeCompressed;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntry.SizeUncompressed Property

C1ZipEntry.SizeUncompressed Property

Gets the original (uncompressed) size of the entry, in bytes.

[Visual Basic]

Public ReadOnly Property SizeUncompressed As Integer

[C#]

public int SizeUncompressed {get;}

[Delphi]

public property SizeUncompressed: Int32 read get_SizeUncompressed;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntry Methods

C1ZipEntry Methods

The methods of the C1ZipEntry class are listed here. For a complete list of C1ZipEntry class members, see the C1ZipEntry Members topic.

Public Methods

CheckCRC32 | Calculates a checksum value for the entry and compares it to the checksum that was stored when the entry was created.
OpenReader | Returns a Stream that can be used to read the content of the entry without extracting it to a disk file.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntry.CheckCRC32 Method

C1ZipEntry.CheckCRC32 Method

Calculates a checksum value for the entry and compares it to the checksum that was stored when the entry was created.

[Visual Basic]

Public Function CheckCRC32() As Boolean

[C#]

public bool CheckCRC32()

[Delphi]

public function CheckCRC32(): Boolean;

Return Value

True if the checksum values match, False otherwise.

Remarks

This method is used to check the integrity of the entries in the zip file. If the calculated checksum does not match the stored checksum, then either the zip file is corrupted or the program used to create the zip file is incompatible with C1Zip .

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntry.OpenReader Method

C1ZipEntry.OpenReader Method

Returns a Stream that can be used to read the content of the entry without extracting it to a disk file.

[Visual Basic]

Public Function OpenReader() As Stream

[C#]

public Stream OpenReader()

[Delphi]

public function OpenReader(): Stream;

Return Value

A Stream that can be used to read the data in the entry.

Remarks

The Stream returned is a C1ZipStreamReader , which decompressed the data as it is read from the entry.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection Class

C1ZipEntryCollection Class

A collection of C1ZipEntry objects that represent the contents of a zip file.

For a list of all members of this type, see C1ZipEntryCollection Members.

System.Object

C1.C1Zip.C1ZipEntryCollection

[Visual Basic]

Public Class C1ZipEntryCollection

Implements ICollection, IEnumerable

[C#]

public class C1ZipEntryCollection : ICollection, IEnumerable

[Delphi]

type C1ZipEntryCollection = class (TObject,(TObject, ICollection, IEnumerable);

Remarks

Use the C1ZipEntryCollection to programmatically manage the contents of zip files. You can add, remove, extract, or insert items into the C1ZipEntryCollection .

Namespace: C1.C1Zip

Assembly: C1.C1Zip (in c1.c1zip.dll)

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection Members

C1ZipEntryCollection Members

C1ZipEntryCollection overview

Public Properties

Count | Gets the number of entries in the current zip file.
Item | Overloaded. Gets the C1ZipEntry at the specified index.

Public Methods

Add | Overloaded. Adds a stream to the current zip file.
Extract | Overloaded. Extracts a file from the current zip file.
OpenWriter | Opens a stream for writing an entry into the zip file.
Remove | Overloaded. Removes an entry from the current zip file.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection Properties

C1ZipEntryCollection Properties

The properties of the C1ZipEntryCollection class are listed here. For a complete list of C1ZipEntryCollection class members, see the C1ZipEntryCollection Members topic.

Public Properties

Count | Gets the number of entries in the current zip file.
Item | Overloaded. Gets the C1ZipEntry at the specified index.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection.Count Property

C1ZipEntryCollection.Count Property

Gets the number of entries in the current zip file.

[Visual Basic]

Overridable Public ReadOnly Property Count As Integer Implements ICollection.Count

[C#]

virtual public int Count {get;}

[Delphi]

public property Count: Int32 read get_Count;

Implements

ICollection.Count

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection.Item Property

C1ZipEntryCollection.Item Property

Overload List

Gets the C1ZipEntry at the specified index.

[Visual Basic] Overloads Public Default ReadOnly Property Item(Integer) As C1ZipEntry

[C#] public C1ZipEntry this[int]{get;}

[Delphi] public property Item[index: Int32]: C1ZipEntry read get_Item;

Gets the C1ZipEntry with the given name (returns null if the entry cannot be found).

[Visual Basic] Overloads Public Default ReadOnly Property Item(String) As C1ZipEntry

[C#] public C1ZipEntry this[string]{get;}

[Delphi] public property Item[name: String]: C1ZipEntry read get_Item;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection.Item Property (Int32)

C1ZipEntryCollection.Item Property (Int32)

Gets the C1ZipEntry at the specified index.

[Visual Basic]

Public Default ReadOnly Property Item( _

ByVal index As Integer _

) As C1ZipEntry

[C#]

public C1ZipEntry this[

int index

] {get;}

[Delphi]

public property Item[

index: Int32

]: C1ZipEntry read get_Item;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection.Item Property (String)

C1ZipEntryCollection.Item Property (String)

Gets the C1ZipEntry with the given name (returns null if the entry cannot be found).

[Visual Basic]

Public Default ReadOnly Property Item( _

ByVal name As String _

) As C1ZipEntry

[C#]

public C1ZipEntry this[

string name

] {get;}

[Delphi]

public property Item[

name: String

]: C1ZipEntry read get_Item;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection Methods

C1ZipEntryCollection Methods

The methods of the C1ZipEntryCollection class are listed here. For a complete list of C1ZipEntryCollection class members, see the C1ZipEntryCollection Members topic.

Public Methods

Add | Overloaded. Adds a stream to the current zip file.
Extract | Overloaded. Extracts a file from the current zip file.
OpenWriter | Opens a stream for writing an entry into the zip file.
Remove | Overloaded. Removes an entry from the current zip file.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection.Add Method

C1ZipEntryCollection.Add Method

Overload List

Adds a stream to the current zip file.

[Visual Basic] Overloads Public Sub Add(Stream, String)

[C#] public Add(Stream, string);

[Delphi] public procedure Add(Stream; String); overload;

Adds an entry to the current zip file.

[Visual Basic] Overloads Public Sub Add(String)

[C#] public Add(string);

[Delphi] public procedure Add(String); overload;

Adds a list of entries to the current zip file.

[Visual Basic] Overloads Public Sub Add(String())

[C#] public Add(string[]);

[Delphi] public procedure Add(array of String); overload;

Adds an entry to the current zip file.

[Visual Basic] Overloads Public Sub Add(String, Integer)

[C#] public Add(string, int);

[Delphi] public procedure Add(String; Int32); overload;

Adds an entry to the current zip file.

[Visual Basic] Overloads Public Sub Add(String, String)

[C#] public Add(string, string);

[Delphi] public procedure Add(String; String); overload;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection.Add Method (Stream, String)

C1ZipEntryCollection.Add Method (Stream, String)

Adds a stream to the current zip file.

[Visual Basic]

Overloads Public Sub Add( _

ByVal stream As Stream, _

ByVal entryName As String _

)

[C#]

public void Add(

Stream stream,

string entryName

);

[Delphi]

public procedure Add(

stream: Stream;

entryName: String

); overload;

Parameters

stream

Stream that contains data for the new entry.

entryName

Name to be used for the new entry.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection.Add Method (String)

C1ZipEntryCollection.Add Method (String)

Adds an entry to the current zip file.

[Visual Basic]

Overloads Public Sub Add( _

ByVal fileName As String _

)

[C#]

public void Add(

string fileName

);

[Delphi]

public procedure Add(

fileName: String

); overload;

Parameters

fileName

Name of the file to add to the zip file.

Remarks

By default, the directory name is not stored in the zip file. To store a specific part of the directory name in the zip file, use the overloaded version of the Add method with a pathLevels parameter.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection.Add Method (String[])

C1ZipEntryCollection.Add Method (String[])

Adds a list of entries to the current zip file.

[Visual Basic]

Overloads Public Sub Add( _

ByVal fileNames As String() _

)

[C#]

public void Add(

string[] fileNames

);

[Delphi]

public procedure Add(

fileNames: array of String

); overload;

Parameters

fileNames

Array containing the file names of the entries to be added to the zip file.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection.Add Method (String, Int32)

C1ZipEntryCollection.Add Method (String, Int32)

Adds an entry to the current zip file.

[Visual Basic]

Overloads Public Sub Add( _

ByVal fileName As String, _

ByVal pathLevels As Integer _

)

[C#]

public void Add(

string fileName,

int pathLevels

);

[Delphi]

public procedure Add(

fileName: String;

pathLevels: Int32

); overload;

Parameters

fileName

Name of the file to add to the zip file.

pathLevels

The number of path levels to be stored as the entry name.

Remarks

By default, path names are not stored in the zip file. For example, adding the file "c:\temp\samples\readme.txt" to the zip file will create an entry called "readme.txt".

The pathLevels parameter allows you to store one or more levels of the path in the entry name. For example, adding the file "c:\temp\samples\readme.txt" to the zip file with pathLevels=1 will create an entry called "samples\readme.txt".

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection.Add Method (String, String)

C1ZipEntryCollection.Add Method (String, String)

Adds an entry to the current zip file.

[Visual Basic]

Overloads Public Sub Add( _

ByVal fileName As String, _

ByVal entryName As String _

)

[C#]

public void Add(

string fileName,

string entryName

);

[Delphi]

public procedure Add(

fileName: String;

entryName: String

); overload;

Parameters

fileName

Name of the file to add to the zip file.

entryName

Name of the new entry as stored in the zip file.

Remarks

By default, entries in the zip file have the same name as the original (uncompressed) file. This method allows you to specify a different name, including a path for example.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection.Extract Method

C1ZipEntryCollection.Extract Method

Overload List

Extracts a file from the current zip file.

[Visual Basic] Overloads Public Sub Extract(Integer)

[C#] public Extract(int);

[Delphi] public procedure Extract(Int32); overload;

Extracts a file from the current zip file.

[Visual Basic] Overloads Public Sub Extract(String)

[C#] public Extract(string);

[Delphi] public procedure Extract(String); overload;

Extracts a file from the current zip file.

[Visual Basic] Overloads Public Sub Extract(Integer, String)

[C#] public Extract(int, string);

[Delphi] public procedure Extract(Int32; String); overload;

Extracts a file from the current zip file.

[Visual Basic] Overloads Public Sub Extract(String, String)

[C#] public Extract(string, string);

[Delphi] public procedure Extract(String; String); overload;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection.Extract Method (Int32)

C1ZipEntryCollection.Extract Method (Int32)

Extracts a file from the current zip file.

[Visual Basic]

Overloads Public Sub Extract( _

ByVal index As Integer _

)

[C#]

public void Extract(

int index

);

[Delphi]

public procedure Extract(

index: Int32

); overload;

Parameters

index

Index of the entry to extract.

Remarks

The entry is extracted to a file in the same folder as the current zip file, with the same name as the entry.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection.Extract Method (String)

C1ZipEntryCollection.Extract Method (String)

Extracts a file from the current zip file.

[Visual Basic]

Overloads Public Sub Extract( _

ByVal entryName As String _

)

[C#]

public void Extract(

string entryName

);

[Delphi]

public procedure Extract(

entryName: String

); overload;

Parameters

entryName

Name of the entry to extract.

Remarks

The entry is extracted to a file in the same folder as the current zip file, with the same name as the entry.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection.Extract Method (Int32, String)

C1ZipEntryCollection.Extract Method (Int32, String)

Extracts a file from the current zip file.

[Visual Basic]

Overloads Public Sub Extract( _

ByVal index As Integer, _

ByVal destFileName As String _

)

[C#]

public void Extract(

int index,

string destFileName

);

[Delphi]

public procedure Extract(

index: Int32;

destFileName: String

); overload;

Parameters

index

Index of the entry to extract.

destFileName

Name and location of the extracted file.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection.Extract Method (String, String)

C1ZipEntryCollection.Extract Method (String, String)

Extracts a file from the current zip file.

[Visual Basic]

Overloads Public Sub Extract( _

ByVal entryName As String, _

ByVal destFileName As String _

)

[C#]

public void Extract(

string entryName,

string destFileName

);

[Delphi]

public procedure Extract(

entryName: String;

destFileName: String

); overload;

Parameters

entryName

Name of the entry to extract.

destFileName

Name and location of the extracted file.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection.OpenWriter Method

C1ZipEntryCollection.OpenWriter Method

Opens a stream for writing an entry into the zip file.

[Visual Basic]

Public Function OpenWriter( _

ByVal entryName As String, _

ByVal useMemory As Boolean _

) As Stream

[C#]

public Stream OpenWriter(

string entryName,

bool useMemory

);

[Delphi]

public function OpenWriter(

entryName: String;

useMemory: Boolean

): Stream;

Parameters

entryName

The name of the new entry.

useMemory

Whether to use a memory stream or temporary file.

Return Value

A stream that can be used to write data into the zip file. The entry is not added until the stream is closed.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection.Remove Method

C1ZipEntryCollection.Remove Method

Overload List

Removes an entry from the current zip file.

[Visual Basic] Overloads Public Sub Remove(Integer)

[C#] public Remove(int);

[Delphi] public procedure Remove(Int32); overload;

Removes several entries from the current zip file.

[Visual Basic] Overloads Public Sub Remove(Integer())

[C#] public Remove(int[]);

[Delphi] public procedure Remove(array of Int32); overload;

Removes an entry from the current zip file.

[Visual Basic] Overloads Public Sub Remove(String)

[C#] public Remove(string);

[Delphi] public procedure Remove(String); overload;

Removes several entries from the current zip file.

[Visual Basic] Overloads Public Sub Remove(String())

[C#] public Remove(string[]);

[Delphi] public procedure Remove(array of String); overload;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection.Remove Method (Int32)

C1ZipEntryCollection.Remove Method (Int32)

Removes an entry from the current zip file.

[Visual Basic]

Overloads Public Sub Remove( _

ByVal index As Integer _

)

[C#]

public void Remove(

int index

);

[Delphi]

public procedure Remove(

index: Int32

); overload;

Parameters

index

Index of the entry to remove.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection.Remove Method (Int32[])

C1ZipEntryCollection.Remove Method (Int32[])

Removes several entries from the current zip file.

[Visual Basic]

Overloads Public Sub Remove( _

ByVal indices As Integer() _

)

[C#]

public void Remove(

int[] indices

);

[Delphi]

public procedure Remove(

indices: array of Int32

); overload;

Parameters

indices

Array containing the indices of the entries to remove.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection.Remove Method (String)

C1ZipEntryCollection.Remove Method (String)

Removes an entry from the current zip file.

[Visual Basic]

Overloads Public Sub Remove( _

ByVal fileName As String _

)

[C#]

public void Remove(

string fileName

);

[Delphi]

public procedure Remove(

fileName: String

); overload;

Parameters

fileName

Name of the entry to remove (case-insensitive).

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipEntryCollection.Remove Method (String[])

C1ZipEntryCollection.Remove Method (String[])

Removes several entries from the current zip file.

[Visual Basic]

Overloads Public Sub Remove( _

ByVal entryNames As String() _

)

[C#]

public void Remove(

string[] entryNames

);

[Delphi]

public procedure Remove(

entryNames: array of String

); overload;

Parameters

entryNames

Array containing the names of the entries to remove.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile Class

C1ZipFile Class

Used for creating, opening, and managing zip files.

For a list of all members of this type, see C1ZipFile Members.

System.Object

C1.C1Zip.C1ZipFile

[Visual Basic]

Public Class C1ZipFile

Implements IDisposable

[C#]

public class C1ZipFile : IDisposable

[Delphi]

type C1ZipFile = class(TObject,(TObject, IDisposable);

Remarks

Use the Open or Create methods to associate the C1Zip file object with a zip file on disk. Then use the Entries property to add, remove, retrieve, or inspect individual entries in the zip file.

C1ZipFile can only be used with standard zip files. The component does not support other similar formats such as gzip, zip2, tar, or rar.

The standard zip file imposes some limitations on the size of each entry. You cannot use it to compress files larger than 4 gigabytes (uint.MaxValue).

Example

The code below creates a zip file called sources.zip and adds all files with a "cs" extension to the zip file:

// get path for zip file and files to compress

string path = Application.ExecutablePath;

int pos = path.IndexOf(@"\bin");

path = path.Substring(0, pos + 1);

// create a zip file

C1ZipFile zip = new C1ZipFile();

zip.Create(path + "source.zip");

// add all files with extension cs to the zip file

foreach (string fileName in Directory.GetFiles(path, "*.cs"))

zip.Entries.Add(fileName);

// show result

foreach (C1ZipEntry ze in zip.Entries)

{

Console.WriteLine("{0} {1:#,##0} {2:#,##0}",

ze.FileName, ze.SizeUncompressed, ze.SizeCompressed);

}

Namespace: C1.C1Zip

Assembly: C1.C1Zip (in c1.c1zip.dll)

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile Members

C1ZipFile Members

C1ZipFile overview

Public Constructors

C1ZipFile Constructor

Initializes a new instance of the C1ZipFile class.

Public Properties

Comment | Gets or sets a comment associated with the current zip file.
CompressionLevel | Gets or sets the compression level to use when adding entries to the zip file.
Entries | Gets the collection of entries in the zip file.
FileName | Gets the name of the current zip file.
MemoryThreshold | Gets or sets the size of the largest stream to be compressed in memory.
OverwriteHidden | Determines whether the component should overwrite hidden files when extracting entries from the zip file.
OverwriteReadOnly | Determines whether the component should overwrite read-only files when extracting entries from the zip file.
OverwriteSystem | Determines whether the component should overwrite system files when extracting entries from the zip file.
Password | Gets or sets the password to use when adding or retrieving entries from the zip file.
TempFileName | Gets or sets the name of the temporary file to use when adding entries to the zip file.

Public Methods

Close | Resets all data members of the C1ZipFile object.
CloseBatch | Closes a zip file after it was opened with a call to the OpenBatch method.
Create | Creates an empty zip file on disk.
IsZipFile | Tests whether a file is a valid zip file.
Open | Opens an existing zip file.
OpenBatch | Opens the zip file for multiple operations.
Refresh | Refreshes all data members by re-opening the current zip file.

Public Events

Progress

Fired while data is being read from or written into a zip file.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile Constructor

C1ZipFile Constructor

Initializes a new instance of the C1ZipFile class.

[Visual Basic]

Public Function New()

[C#]

public C1ZipFile()

[Delphi]

public constructor Create();

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile Properties

C1ZipFile Properties

The properties of the C1ZipFile class are listed here. For a complete list of C1ZipFile class members, see the C1ZipFile Members topic.

Public Properties

Comment | Gets or sets a comment associated with the current zip file.
CompressionLevel | Gets or sets the compression level to use when adding entries to the zip file.
Entries | Gets the collection of entries in the zip file.
FileName | Gets the name of the current zip file.
MemoryThreshold | Gets or sets the size of the largest stream to be compressed in memory.
OverwriteHidden | Determines whether the component should overwrite hidden files when extracting entries from the zip file.
OverwriteReadOnly | Determines whether the component should overwrite read-only files when extracting entries from the zip file.
OverwriteSystem | Determines whether the component should overwrite system files when extracting entries from the zip file.
Password | Gets or sets the password to use when adding or retrieving entries from the zip file.
TempFileName | Gets or sets the name of the temporary file to use when adding entries to the zip file.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile.Comment Property

C1ZipFile.Comment Property

Gets or sets a comment associated with the current zip file.

[Visual Basic]

Public Property Comment As String

[C#]

public string Comment {get;set;}

[Delphi]

public property Comment: String read get_Comment write set_Comment;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile.CompressionLevel Property

C1ZipFile.CompressionLevel Property

Gets or sets the compression level to use when adding entries to the zip file.

[Visual Basic]

Public Property CompressionLevel As CompressionLevelEnum

[C#]

public CompressionLevelEnum CompressionLevel {get;set;}

[Delphi]

public property CompressionLevel: CompressionLevelEnum read get_CompressionLevel write set_CompressionLevel;

Remarks

Higher compression settings create smaller files, but take longer to process. The default setting ( DefaultCompression ) provides a good trade-off between compression and speed.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile.Entries Property

C1ZipFile.Entries Property

Gets the collection of entries in the zip file.

[Visual Basic]

Public ReadOnly Property Entries As C1ZipEntryCollection

[C#]

public C1ZipEntryCollection Entries {get;}

[Delphi]

public property Entries: C1ZipEntryCollection read get_Entries;

Remarks

The Entries collection is used to enumerate the entries in the zip file, and also to add, remove, and expand entries.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile.FileName Property

C1ZipFile.FileName Property

Gets the name of the current zip file.

[Visual Basic]

Public ReadOnly Property FileName As String

[C#]

public string FileName {get;}

[Delphi]

public property FileName: String read get_FileName;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile.MemoryThreshold Property

C1ZipFile.MemoryThreshold Property

Gets or sets the size of the largest stream to be compressed in memory.

[Visual Basic]

Public Property MemoryThreshold As Integer

[C#]

public int MemoryThreshold {get;set;}

[Delphi]

public property MemoryThreshold: Int32 read get_MemoryThreshold write set_MemoryThreshold;

Remarks

C1ZipFile compresses entries into temporary streams before adding them to the zip file.

Entries with fewer than MemoryThreshold bytes are compressed using a temporary memory stream.

Entries with more than MemoryThreshold bytes are compressed using a temporary file. You can control the location of the temporary file using the TempFileName property.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile.OverwriteHidden Property

C1ZipFile.OverwriteHidden Property

Determines whether the component should overwrite hidden files when extracting entries from the zip file.

[Visual Basic]

Public Property OverwriteHidden As Boolean

[C#]

public bool OverwriteHidden {get;set;}

[Delphi]

public property OverwriteHidden: Boolean read get_OverwriteHidden write set_OverwriteHidden;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile.OverwriteReadOnly Property

C1ZipFile.OverwriteReadOnly Property

Determines whether the component should overwrite read-only files when extracting entries from the zip file.

[Visual Basic]

Public Property OverwriteReadOnly As Boolean

[C#]

public bool OverwriteReadOnly {get;set;}

[Delphi]

public property OverwriteReadOnly: Boolean read get_OverwriteReadOnly write set_OverwriteReadOnly;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile.OverwriteSystem Property

C1ZipFile.OverwriteSystem Property

Determines whether the component should overwrite system files when extracting entries from the zip file.

[Visual Basic]

Public Property OverwriteSystem As Boolean

[C#]

public bool OverwriteSystem {get;set;}

[Delphi]

public property OverwriteSystem: Boolean read get_OverwriteSystem write set_OverwriteSystem;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile.Password Property

C1ZipFile.Password Property

Gets or sets the password to use when adding or retrieving entries from the zip file.

[Visual Basic]

Public Property Password As String

[C#]

public string Password {get;set;}

[Delphi]

public property Password: String read get_Password write set_Password;

Remarks

If the Password property is set to a non-empty string, any entries added to the zip file will be encrypted and protected by the password. To extract these entries later, the same password must be used.

The password applies to all entries from the moment it is set. If you set the password to a non-empty string and then add several entries to the zip file, all entries will use the same password.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile.TempFileName Property

C1ZipFile.TempFileName Property

Gets or sets the name of the temporary file to use when adding entries to the zip file.

[Visual Basic]

Public Property TempFileName As String

[C#]

public string TempFileName {get;set;}

[Delphi]

public property TempFileName: String read get_TempFileName write set_TempFileName;

Remarks

C1ZipFile creates temporary streams while adding entries to a zip file. These temporary streams can be memory-based or disk-based, depending on the size of the entry and on the setting of the MemoryThreshold property. If a temporary file is used, C1ZipFile you can control its location by setting the TempFileName property. If you don't select a path for the temporary file, C1ZipFile will create one automatically using the System.IO.Path.GetTempFileName method.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile Methods

C1ZipFile Methods

The methods of the C1ZipFile class are listed here. For a complete list of C1ZipFile class members, see the C1ZipFile Members topic.

Public Methods

Close | Resets all data members of the C1ZipFile object.
CloseBatch | Closes a zip file after it was opened with a call to the OpenBatch method.
Create | Creates an empty zip file on disk.
IsZipFile | Tests whether a file is a valid zip file.
Open | Opens an existing zip file.
OpenBatch | Opens the zip file for multiple operations.
Refresh | Refreshes all data members by re-opening the current zip file.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile.Close Method

C1ZipFile.Close Method

Resets all data members of the C1ZipFile object.

[Visual Basic]

Public Sub Close()

[C#]

public void Close()

[Delphi]

public procedure Close();

Remarks

Disk files are automatically closed by C1Zip . You only need to use the Close method if you want to break the connection between a C1ZipFile class and a physical zip file.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile.CloseBatch Method

C1ZipFile.CloseBatch Method

Closes a zip file after it was opened with a call to the OpenBatch method.

[Visual Basic]

Public Sub CloseBatch()

[C#]

public void CloseBatch()

[Delphi]

public procedure CloseBatch();

Remarks

See the OpenBatch method for a complete description and a sample.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile.Create Method

C1ZipFile.Create Method

Creates an empty zip file on disk.

[Visual Basic]

Public Sub Create( _

ByVal fileName As String _

)

[C#]

public void Create(

string fileName

);

[Delphi]

public procedure Create(

fileName: String

);

Parameters

fileName

The name of the zip file to create, including the path.

Remarks

If a file by the same name already exists, it is deleted before the new one is created.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile.IsZipFile Method

C1ZipFile.IsZipFile Method

Tests whether a file is a valid zip file.

[Visual Basic]

Public Shared Function IsZipFile( _

ByVal fileName As String _

) As Boolean

[C#]

public static bool IsZipFile(

string fileName

);

[Delphi]

public class function IsZipFile(

fileName: String

): Boolean;

Parameters

fileName

Name of the file to test.

Return Value

True if the file is a valid zip file, False otherwise.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile.Open Method

C1ZipFile.Open Method

Opens an existing zip file.

[Visual Basic]

Public Sub Open( _

ByVal fileName As String _

)

[C#]

public void Open(

string fileName

);

[Delphi]

public procedure Open(

fileName: String

);

Parameters

fileName

The name of an existing zip file, including the path.

Remarks

The Open method checks that the zip file exists and is a valid zip file, then reads the zip file directory into the Entries collection. The zip file is then closed, and can be used by other applications. There is no need to close the zip file explicitly.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile.OpenBatch Method

C1ZipFile.OpenBatch Method

Opens the zip file for multiple operations.

[Visual Basic]

Public Sub OpenBatch()

[C#]

public void OpenBatch()

[Delphi]

public procedure OpenBatch();

Remarks

By default, C1ZipFile opens and closes the zip file automatically whenever entries are added or removed.

This can cause delays in systems that have certain types of anti-virus software installed, or in situations where you want to add a large number of relatively small entries. In these cases, use the OpenBatch and CloseBatch methods to keep the zip file open until the entire operation is concluded.

Use a finally clause to ensure that the CloseBatch method is called even if an exception occurs.

Example

The code below opens a zip file, adds several entries to it, then closes the file:

C1ZipFile zip = new C1ZipFile();

zip.Open(myzipfile);

try

{

zip.OpenBatch();

foreach (string fileName in Directory.GetFiles(path, "*.*"))

zip.Entries.Add(fileName);

}

finally

{

zip.CloseBatch();

}

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile.Refresh Method

C1ZipFile.Refresh Method

Refreshes all data members by re-opening the current zip file.

[Visual Basic]

Public Sub Refresh()

[C#]

public void Refresh()

[Delphi]

public procedure Refresh();

Remarks

This method is useful in instances where other applications may have changed the zip file and you want to make sure the information in the Entriescollection is up to date.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile Events

C1ZipFile Events

The events of the C1ZipFile class are listed here. For a complete list of C1ZipFile class members, see the C1ZipFile Members topic.

Public Events

Progress

Fired while data is being read from or written into a zip file.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZipFile.Progress Event

C1ZipFile.Progress Event

Fired while data is being read from or written into a zip file.

[Visual Basic]

Public Event Progress As ZipProgressEventHandler

[C#]

public event ZipProgressEventHandler Progress

[Delphi]

public property Progress: ZipProgressEventHandler read remove_Progress write add_Progress;

Remarks

This event is typically used to update the application UI during lengthy operations. It can also be used to cancel the operations.

Example

The code below writes messages to the output window while the application compresses files.

private void Compress()

{

// create zip file

C1Zip zip = new C1Zip();

zip.Create(zipFileName);

// connect event handler

zip.Progress += new ZipProgressEventHandler(zip_Progress);

// add files

foreach (string fileName in Directory.GetFiles(path, "*.*"))

zip.Entries.Add(fileName);

}

// print messages while files are compressed

private void zip_Progress(object sender, ZipProgressEventArgs e)

{

Console.WriteLine("Compressing {0}, {1:p0} done",

e.FileName, e.Position/(float)e.FileLength);

}

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader Class

C1ZStreamReader Class

Decompresses data from .NET streams.

For a list of all members of this type, see C1ZStreamReader Members.

System.Object

System.MarshalByRefObject

System.IO.Stream

C1.C1Zip.C1ZStreamReader

[Visual Basic]

Public Class C1ZStreamReader

Inherits Stream

[C#]

public class C1ZStreamReader : Stream

[Delphi]

type C1ZStreamReader = class(Stream);(Stream);

Remarks

To decompress data from a compressed stream, create a C1ZStreamReader object passing the compressed stream to the C1ZStreamReader constructor.

Then read the data from the C1ZStreamReader using the Readmethod, or create a System.IO.StreamReader on the C1ZStreamReader. The second option is indicated when you want to read formatted data.

Example

The code below decompresses a string that was stored into a memory stream object:

public string ExpandString(byte[] buffer)

{

// turn buffer into a memory stream

MemoryStream ms = new MemoryStream(buffer);

// attach decompressor stream to memory stream

C1ZStreamReader sr = new C1ZStreamReader(ms);

// read uncompressed data

StreamReader reader = new StreamReader(sr);

return reader.ReadToEnd();

}

Namespace: C1.C1Zip

Assembly: C1.C1Zip (in c1.c1zip.dll)

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader Members

C1ZStreamReader Members

C1ZStreamReader overview

Public Constructors

C1ZStreamReader Constructor

Initializes a new instance of the C1ZStreamReader class.

Public Properties

BaseStream | Gets the underlying stream that contains the compressed data.
CanRead | Overriden. Always returns True.
CanSeek | Overriden. Always returns False.
CanWrite | Overriden. Always returns False.
Length | Overriden. Gets the length of the compressed stream if it is known (or -1 if the length of the compressed stream is unknown).
OwnsBaseStream | Gets or sets whether calling the Close method will also close the underlying stream (see BaseStream).
Position | Overriden. Gets the position within the stream (read-only).
SizeCompressed | Gets the number of bytes in the stream (compressed bytes).
SizeUncompressed | Gets the number of bytes that were compressed into the stream (uncompressed bytes).
ZStream | Gets the ZStream instance wrapped by this C1ZStreamWriter.

Public Methods

Close

Overriden. Closes the current stream compressor and flushed any pending data into the base stream.

If the OwnsBaseStream property is set to True (the default value), then this method also closes the base stream and releases any resources (such as sockets and file handles) associated with it.

Flush

Overriden. Clears all buffers for this stream and causes any buffered data to be written to the underlying stream.

Read

Overriden. Reads a sequence of bytes from the underlying compressed stream, decompressing them into a buffer, then dvances the position within the stream by the number of bytes read.

ReadByte

Overriden. Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

Seek

Overriden. Not supported.

SetLength

Overriden. Sets the number of compressed bytes to read from the underlying stream.

Write

Overriden. This method is overriden and is not supported by the C1ZStreamReader class.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader Constructor

C1ZStreamReader Constructor

Overload List

Initializes a new instance of the C1ZStreamReader class.

[Visual Basic] Public Function New(Stream)

[C#] public C1ZStreamReader(Stream);

[Delphi] public constructor Create(Stream); overload;

Initializes a new instance of the C1ZStreamReader class.

[Visual Basic] Public Function New(Stream, Boolean)

[C#] public C1ZStreamReader(Stream, bool);

[Delphi] public constructor Create(Stream; Boolean); overload;

Initializes a new instance of the C1ZStreamReader class.

[Visual Basic] Public Function New(Stream, Boolean, Boolean)

[C#] public C1ZStreamReader(Stream, bool, bool);

[Delphi] public constructor Create(Stream; Boolean; Boolean); overload;

Initializes a new instance of the C1ZStreamReader class.

[Visual Basic] Public Function New(Stream, Boolean, Integer)

[C#] public C1ZStreamReader(Stream, bool, int);

[Delphi] public constructor Create(Stream; Boolean; Int32); overload;

Initializes a new instance of the C1ZStreamReader class.

[Visual Basic] Public Function New(Stream, Boolean, Integer, Integer)

[C#] public C1ZStreamReader(Stream, bool, int, int);

[Delphi] public constructor Create(Stream; Boolean; Int32; Int32); overload;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader Constructor (Stream)

C1ZStreamReader Constructor (Stream)

Initializes a new instance of the C1ZStreamReader class.

[Visual Basic]

Public Function New( _

ByVal baseStream As Stream _

)

[C#]

public C1ZStreamReader(

Stream baseStream

);

[Delphi]

public constructor Create(

baseStream: Stream

); overload;

Parameters

baseStream

Input stream that contains the compressed data.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader Constructor (Stream, Boolean)

C1ZStreamReader Constructor (Stream, Boolean)

Initializes a new instance of the C1ZStreamReader class.

[Visual Basic]

Public Function New( _

ByVal baseStream As Stream, _

ByVal zip As Boolean _

)

[C#]

public C1ZStreamReader(

Stream baseStream,

bool zip

);

[Delphi]

public constructor Create(

baseStream: Stream;

zip: Boolean

); overload;

Parameters

baseStream

Input stream that contains the compressed data.

zip

Specifies whether the compressed stream was created in zip format.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader Constructor (Stream, Boolean, Boolean)

C1ZStreamReader Constructor (Stream, Boolean, Boolean)

Initializes a new instance of the C1ZStreamReader class.

[Visual Basic]

Public Function New( _

ByVal baseStream As Stream, _

ByVal header As Boolean, _

ByVal crc32 As Boolean _

)

[C#]

public C1ZStreamReader(

Stream baseStream,

bool header,

bool crc32

);

[Delphi]

public constructor Create(

baseStream: Stream;

header: Boolean;

crc32: Boolean

); overload;

Parameters

baseStream

Input stream that contains the compressed data.

header

Specifies whether the compressed stream contains header information (should be False for streams in zip files).

crc32

Specifies whether the compressed stream contains a CRC32 checksum (should be True for streams in zip files).

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader Constructor (Stream, Boolean, Int32)

C1ZStreamReader Constructor (Stream, Boolean, Int32)

Initializes a new instance of the C1ZStreamReader class.

[Visual Basic]

Public Function New( _

ByVal baseStream As Stream, _

ByVal zip As Boolean, _

ByVal sizeCompressed As Integer _

)

[C#]

public C1ZStreamReader(

Stream baseStream,

bool zip,

int sizeCompressed

);

[Delphi]

public constructor Create(

baseStream: Stream;

zip: Boolean;

sizeCompressed: Int32

); overload;

Parameters

baseStream

Input stream that contains the compressed data.

zip

Specifies whether the compressed stream was created in zip format.

sizeCompressed

Specifies the number of compressed bytes to read from the stream.

Remarks

The sizeCompressed parameter is needed only when a single stream contains several compressed streams (in zip files for example). If this parameter is not specified, it is assumed that the stream contains a single stream of compressed data.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader Constructor (Stream, Boolean, Int32, Int32)

C1ZStreamReader Constructor (Stream, Boolean, Int32, Int32)

Initializes a new instance of the C1ZStreamReader class.

[Visual Basic]

Public Function New( _

ByVal baseStream As Stream, _

ByVal zip As Boolean, _

ByVal sizeCompressed As Integer, _

ByVal method As Integer _

)

[C#]

public C1ZStreamReader(

Stream baseStream,

bool zip,

int sizeCompressed,

int method

);

[Delphi]

public constructor Create(

baseStream: Stream;

zip: Boolean;

sizeCompressed: Int32;

method: Int32

); overload;

Parameters

baseStream

Input stream that contains the compressed data.

zip

Specifies whether the compressed stream was created in zip format.

sizeCompressed

Specifies the number of compressed bytes to read from the stream.

method

Specifies the method that was used to compress the stream.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader Properties

C1ZStreamReader Properties

The properties of the C1ZStreamReader class are listed here. For a complete list of C1ZStreamReader class members, see the C1ZStreamReader Members topic.

Public Properties

BaseStream | Gets the underlying stream that contains the compressed data.
CanRead | Overriden. Always returns True.
CanSeek | Overriden. Always returns False.
CanWrite | Overriden. Always returns False.
Length | Overriden. Gets the length of the compressed stream if it is known (or -1 if the length of the compressed stream is unknown).
OwnsBaseStream | Gets or sets whether calling the Close method will also close the underlying stream (see BaseStream).
Position | Overriden. Gets the position within the stream (read-only).
SizeCompressed | Gets the number of bytes in the stream (compressed bytes).
SizeUncompressed | Gets the number of bytes that were compressed into the stream (uncompressed bytes).
ZStream | Gets the ZStream instance wrapped by this C1ZStreamWriter.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader.BaseStream Property

C1ZStreamReader.BaseStream Property

Gets the underlying stream that contains the compressed data.

[Visual Basic]

Public ReadOnly Property BaseStream As Stream

[C#]

public Stream BaseStream {get;}

[Delphi]

public property BaseStream: Stream read get_BaseStream;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader.CanRead Property

C1ZStreamReader.CanRead Property

Always returns True.

[Visual Basic]

Overrides Public ReadOnly Property CanRead As Boolean

[C#]

override public bool CanRead {get;}

[Delphi]

public property CanRead: Boolean read get_CanRead;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader.CanSeek Property

C1ZStreamReader.CanSeek Property

Always returns False.

[Visual Basic]

Overrides Public ReadOnly Property CanSeek As Boolean

[C#]

override public bool CanSeek {get;}

[Delphi]

public property CanSeek: Boolean read get_CanSeek;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader.CanWrite Property

C1ZStreamReader.CanWrite Property

Always returns False.

[Visual Basic]

Overrides Public ReadOnly Property CanWrite As Boolean

[C#]

override public bool CanWrite {get;}

[Delphi]

public property CanWrite: Boolean read get_CanWrite;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader.Length Property

C1ZStreamReader.Length Property

Gets the length of the compressed stream if it is known (or -1 if the length of the compressed stream is unknown).

[Visual Basic]

Overrides Public ReadOnly Property Length As Long

[C#]

override public long Length {get;}

[Delphi]

public property Length: Int64 read get_Length;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader.OwnsBaseStream Property

C1ZStreamReader.OwnsBaseStream Property

Gets or sets whether calling the Close method will also close the underlying stream (see BaseStream).

[Visual Basic]

Public Property OwnsBaseStream As Boolean

[C#]

public bool OwnsBaseStream {get;set;}

[Delphi]

public property OwnsBaseStream: Boolean read get_OwnsBaseStream write set_OwnsBaseStream;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader.Position Property

C1ZStreamReader.Position Property

Gets the position within the stream (read-only).

[Visual Basic]

Overrides Public Property Position As Long

[C#]

override public long Position {get;set;}

[Delphi]

public property Position: Int64 read get_Position write set_Position;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader.SizeCompressed Property

C1ZStreamReader.SizeCompressed Property

Gets the number of bytes in the stream (compressed bytes).

[Visual Basic]

Public ReadOnly Property SizeCompressed As Integer

[C#]

public int SizeCompressed {get;}

[Delphi]

public property SizeCompressed: Int32 read get_SizeCompressed;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader.SizeUncompressed Property

C1ZStreamReader.SizeUncompressed Property

Gets the number of bytes that were compressed into the stream (uncompressed bytes).

[Visual Basic]

Public ReadOnly Property SizeUncompressed As Integer

[C#]

public int SizeUncompressed {get;}

[Delphi]

public property SizeUncompressed: Int32 read get_SizeUncompressed;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader.ZStream Property

C1ZStreamReader.ZStream Property

Gets the ZStream instance wrapped by this C1ZStreamWriter.

[Visual Basic]

Public ReadOnly Property ZStream As ZStream

[C#]

public ZStream ZStream {get;}

[Delphi]

public property ZStream: ZStream read get_ZStream;

Remarks

This property is useful only in advanced applications that need to customize the low-level behavior of the compressor. It is not needed in common appications.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader Methods

C1ZStreamReader Methods

The methods of the C1ZStreamReader class are listed here. For a complete list of C1ZStreamReader class members, see the C1ZStreamReader Members topic.

Public Methods

Close

Overriden. Closes the current stream compressor and flushed any pending data into the base stream.

If the OwnsBaseStream property is set to True (the default value), then this method also closes the base stream and releases any resources (such as sockets and file handles) associated with it.

Flush

Overriden. Clears all buffers for this stream and causes any buffered data to be written to the underlying stream.

Read

Overriden. Reads a sequence of bytes from the underlying compressed stream, decompressing them into a buffer, then dvances the position within the stream by the number of bytes read.

ReadByte

Overriden. Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

Seek

Overriden. Not supported.

SetLength

Overriden. Sets the number of compressed bytes to read from the underlying stream.

Write

Overriden. This method is overriden and is not supported by the C1ZStreamReader class.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader.Close Method

C1ZStreamReader.Close Method

Closes the current stream compressor and flushed any pending data into the base stream.

If the OwnsBaseStream property is set to True (the default value), then this method also closes the base stream and releases any resources (such as sockets and file handles) associated with it.

[Visual Basic]

Overrides Public Sub Close()

[C#]

override public void Close()

[Delphi]

public procedure Close(); override;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader.Flush Method

C1ZStreamReader.Flush Method

Clears all buffers for this stream and causes any buffered data to be written to the underlying stream.

[Visual Basic]

Overrides Public Sub Flush()

[C#]

override public void Flush()

[Delphi]

public procedure Flush(); override;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader.Read Method

C1ZStreamReader.Read Method

Reads a sequence of bytes from the underlying compressed stream, decompressing them into a buffer, then dvances the position within the stream by the number of bytes read.

[Visual Basic]

Overrides Public Function Read( _

ByVal buf As Byte(), _

ByVal offset As Integer, _

ByVal count As Integer _

) As Integer

[C#]

override public int Read(

Byte[] buf,

int offset,

int count

);

[Delphi]

public function Read(

buf: array of Byte;

offset: Int32;

count: Int32

): Int32; override;

Parameters

buf

An array of bytes. When this method returns, buff contains the specified byte array with the values between offsetand ( offset + count) replaced by the uncompressed data read from the stream.

offset

The zero-based byte offset in buff at which to begin storing the data read from the current stream.

count

The maximum number of (decompressed) bytes to be read from the current stream.

Return Value

The total number of bytes read into the buffer. This may be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader.ReadByte Method

C1ZStreamReader.ReadByte Method

Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

[Visual Basic]

Overrides Public Function ReadByte() As Integer

[C#]

override public int ReadByte()

[Delphi]

public function ReadByte(): Int32; override;

Return Value

The unsigned byte cast to an System.Int32, or -1 if at the end of the stream.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader.Seek Method

C1ZStreamReader.Seek Method

Not supported.

[Visual Basic]

Overrides Public Function Seek( _

ByVal offset As Long, _

ByVal origin As SeekOrigin _

) As Long

[C#]

override public long Seek(

long offset,

SeekOrigin origin

);

[Delphi]

public function Seek(

offset: Int64;

origin: SeekOrigin

): Int64; override;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader.SetLength Method

C1ZStreamReader.SetLength Method

Sets the number of compressed bytes to read from the underlying stream.

[Visual Basic]

Overrides Public Sub SetLength( _

ByVal value As Long _

)

[C#]

override public void SetLength(

long value

);

[Delphi]

public procedure SetLength(

value: Int64

); override;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamReader.Write Method

C1ZStreamReader.Write Method

This method is overriden and is not supported by the C1ZStreamReader class.

[Visual Basic]

Overrides Public Sub Write( _

ByVal buf As Byte(), _

ByVal offset As Integer, _

ByVal count As Integer _

)

[C#]

override public void Write(

Byte[] buf,

int offset,

int count

);

[Delphi]

public procedure Write(

buf: array of Byte;

offset: Int32;

count: Int32

); override;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter Class

C1ZStreamWriter Class

Compresses data into .NET Streams.

For a list of all members of this type, see C1ZStreamWriter Members.

System.Object

System.MarshalByRefObject

System.IO.Stream

C1.C1Zip.C1ZStreamWriter

[Visual Basic]

Public Class C1ZStreamWriter

Inherits Stream

[C#]

public class C1ZStreamWriter : Stream

[Delphi]

type C1ZStreamWriter = class(Stream);(Stream);

Remarks

To compress data into a stream, create a C1ZStreamWriter object passing the stream to the C1ZStreamWriter constructor.

Then write the data into the C1ZStreamWriter using the Writemethod, or create a System.IO.StreamWriter on the C1ZStreamWriter. The second option is indicated when you want to write formatted data.

When you are done writing the data, call the Close method to flush the data and close the underlying stream.

Example

The code below compresses a string into a memory stream:

public byte[] CompressString(string str)

{

// open memory stream

MemoryStream ms = new MemoryStream();

// attach compressor stream to memory stream

C1ZStreamWriter sw = new C1ZStreamWriter(ms);

// write data into compressor stream

StreamWriter writer = new StreamWriter(sw);

writer.Write(str);

// flush any pending data

writer.Flush();

// return the memory buffer

return ms.ToArray();

}

Namespace: C1.C1Zip

Assembly: C1.C1Zip (in c1.c1zip.dll)

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter Members

C1ZStreamWriter Members

C1ZStreamWriter overview

Public Constructors

C1ZStreamWriter Constructor

Initializes a new instance of the C1ZStreamWriter class.

Public Properties

BaseStream | Gets the underlying stream that receives the compressed data.
CanRead | Overriden. Always returns False.
CanSeek | Overriden. Always returns False.
CanWrite | Overriden. Always returns True.
Checksum | Gets the checksum value used to check the integrity of the stream.
Length | Overriden. Returns the length of the underlying stream, in bytes.
OwnsBaseStream | Gets or sets whether calling the Close method will also close the underlying stream (see BaseStream).
Position | Overriden. Gets the position within the stream (read-only).
SizeCompressed | Gets the number of bytes in the stream (compressed bytes).
SizeUncompressed | Gets the number of bytes that were compressed into the stream (uncompressed bytes).
ZStream | Gets the ZStream instance wrapped by this C1ZStreamWriter.

Public Methods

Close

Overriden. Closes the current stream compressor and flushed any pending data into the base stream.

If the OwnsBaseStream property is set to True (the default value), then this method also closes the base stream and releases any resources (such as sockets and file handles) associated with it.

Flush

Overriden. Clears all buffers for this stream and causes any buffered data to be written to the underlying stream.

Read

Overriden. Not supported.

Seek

Overriden. Not supported.

SetLength

Overriden. Not supported.

Write

Overriden. Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

WriteByte

Overriden. Writes a byte to the current position in the stream and advances the position within the stream by one byte.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter Constructor

C1ZStreamWriter Constructor

Overload List

Initializes a new instance of the C1ZStreamWriter class.

[Visual Basic] Public Function New(Stream)

[C#] public C1ZStreamWriter(Stream);

[Delphi] public constructor Create(Stream); overload;

Initializes a new instance of the C1ZStreamWriter class.

[Visual Basic] Public Function New(Stream, Boolean)

[C#] public C1ZStreamWriter(Stream, bool);

[Delphi] public constructor Create(Stream; Boolean); overload;

Initializes a new instance of the C1ZStreamWriter class.

[Visual Basic] Public Function New(Stream, CompressionLevelEnum)

[C#] public C1ZStreamWriter(Stream, CompressionLevelEnum);

[Delphi] public constructor Create(Stream; CompressionLevelEnum); overload;

Initializes a new instance of the C1ZStreamWriter class.

[Visual Basic] Public Function New(Stream, Boolean, Boolean)

[C#] public C1ZStreamWriter(Stream, bool, bool);

[Delphi] public constructor Create(Stream; Boolean; Boolean); overload;

Initializes a new instance of the C1ZStreamWriter class.

[Visual Basic] Public Function New(Stream, CompressionLevelEnum, Boolean)

[C#] public C1ZStreamWriter(Stream, CompressionLevelEnum, bool);

[Delphi] public constructor Create(Stream; CompressionLevelEnum; Boolean); overload;

Initializes a new instance of the C1ZStreamWriter class.

[Visual Basic] Public Function New(Stream, CompressionLevelEnum, Boolean, Boolean)

[C#] public C1ZStreamWriter(Stream, CompressionLevelEnum, bool, bool);

[Delphi] public constructor Create(Stream; CompressionLevelEnum; Boolean; Boolean); overload;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter Constructor (Stream)

C1ZStreamWriter Constructor (Stream)

Initializes a new instance of the C1ZStreamWriter class.

[Visual Basic]

Public Function New( _

ByVal baseStream As Stream _

)

[C#]

public C1ZStreamWriter(

Stream baseStream

);

[Delphi]

public constructor Create(

baseStream: Stream

); overload;

Parameters

baseStream

Output stream that will contain the compressed data.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter Constructor (Stream, Boolean)

C1ZStreamWriter Constructor (Stream, Boolean)

Initializes a new instance of the C1ZStreamWriter class.

[Visual Basic]

Public Function New( _

ByVal baseStream As Stream, _

ByVal zip As Boolean _

)

[C#]

public C1ZStreamWriter(

Stream baseStream,

bool zip

);

[Delphi]

public constructor Create(

baseStream: Stream;

zip: Boolean

); overload;

Parameters

baseStream

Output stream that will contain the compressed data.

zip

Specifies whether the compressed stream should be compatible with zip files.

Remarks

Streams in zip files are different from regular zlib streams in two aspects:

(1) zip streams do not contain any local header information (the information is stored in the zip file headers instead) and

(2) zip streams use a CRC32 checksum instead of the adler32 checksum used by zlib streams.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter Constructor (Stream, CompressionLevelEnum)

C1ZStreamWriter Constructor (Stream, CompressionLevelEnum)

Initializes a new instance of the C1ZStreamWriter class.

[Visual Basic]

Public Function New( _

ByVal baseStream As Stream, _

ByVal level As CompressionLevelEnum _

)

[C#]

public C1ZStreamWriter(

Stream baseStream,

CompressionLevelEnum level

);

[Delphi]

public constructor Create(

baseStream: Stream;

level: CompressionLevelEnum

); overload;

Parameters

baseStream

Output stream that will contain the compressed data.

level

Compression level to use when compressing data.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter Constructor (Stream, Boolean, Boolean)

C1ZStreamWriter Constructor (Stream, Boolean, Boolean)

Initializes a new instance of the C1ZStreamWriter class.

[Visual Basic]

Public Function New( _

ByVal baseStream As Stream, _

ByVal header As Boolean, _

ByVal crc32 As Boolean _

)

[C#]

public C1ZStreamWriter(

Stream baseStream,

bool header,

bool crc32

);

[Delphi]

public constructor Create(

baseStream: Stream;

header: Boolean;

crc32: Boolean

); overload;

Parameters

baseStream

Output stream that will contain the compressed data.

header

Include header information in compressed stream (should be False for streams in zip files).

crc32

Include CRC32 checksum in compressed stream (should be True for streams in zip files).

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter Constructor (Stream, CompressionLevelEnum, Boolean)

C1ZStreamWriter Constructor (Stream, CompressionLevelEnum, Boolean)

Initializes a new instance of the C1ZStreamWriter class.

[Visual Basic]

Public Function New( _

ByVal baseStream As Stream, _

ByVal level As CompressionLevelEnum, _

ByVal zip As Boolean _

)

[C#]

public C1ZStreamWriter(

Stream baseStream,

CompressionLevelEnum level,

bool zip

);

[Delphi]

public constructor Create(

baseStream: Stream;

level: CompressionLevelEnum;

zip: Boolean

); overload;

Parameters

baseStream

Output stream that will contain the compressed data.

level

Compression level to use when compressing data.

zip

Specifies whether the compressed stream should be compatible with zip files.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter Constructor (Stream, CompressionLevelEnum, Boolean, Boolean)

C1ZStreamWriter Constructor (Stream, CompressionLevelEnum, Boolean, Boolean)

Initializes a new instance of the C1ZStreamWriter class.

[Visual Basic]

Public Function New( _

ByVal baseStream As Stream, _

ByVal level As CompressionLevelEnum, _

ByVal header As Boolean, _

ByVal crc32 As Boolean _

)

[C#]

public C1ZStreamWriter(

Stream baseStream,

CompressionLevelEnum level,

bool header,

bool crc32

);

[Delphi]

public constructor Create(

baseStream: Stream;

level: CompressionLevelEnum;

header: Boolean;

crc32: Boolean

); overload;

Parameters

baseStream

Output stream that will contain the compressed data.

level

Compression level to use when compressing data.

header

Include header information in compressed stream (should be False for streams in zip files).

crc32

Include CRC32 checksum in compressed stream (should be True for streams in zip files).

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter Properties

C1ZStreamWriter Properties

The properties of the C1ZStreamWriter class are listed here. For a complete list of C1ZStreamWriter class members, see the C1ZStreamWriter Members topic.

Public Properties

BaseStream | Gets the underlying stream that receives the compressed data.
CanRead | Overriden. Always returns False.
CanSeek | Overriden. Always returns False.
CanWrite | Overriden. Always returns True.
Checksum | Gets the checksum value used to check the integrity of the stream.
Length | Overriden. Returns the length of the underlying stream, in bytes.
OwnsBaseStream | Gets or sets whether calling the Close method will also close the underlying stream (see BaseStream).
Position | Overriden. Gets the position within the stream (read-only).
SizeCompressed | Gets the number of bytes in the stream (compressed bytes).
SizeUncompressed | Gets the number of bytes that were compressed into the stream (uncompressed bytes).
ZStream | Gets the ZStream instance wrapped by this C1ZStreamWriter.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter.BaseStream Property

C1ZStreamWriter.BaseStream Property

Gets the underlying stream that receives the compressed data.

[Visual Basic]

Public ReadOnly Property BaseStream As Stream

[C#]

public Stream BaseStream {get;}

[Delphi]

public property BaseStream: Stream read get_BaseStream;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter.CanRead Property

C1ZStreamWriter.CanRead Property

Always returns False.

[Visual Basic]

Overrides Public ReadOnly Property CanRead As Boolean

[C#]

override public bool CanRead {get;}

[Delphi]

public property CanRead: Boolean read get_CanRead;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter.CanSeek Property

C1ZStreamWriter.CanSeek Property

Always returns False.

[Visual Basic]

Overrides Public ReadOnly Property CanSeek As Boolean

[C#]

override public bool CanSeek {get;}

[Delphi]

public property CanSeek: Boolean read get_CanSeek;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter.CanWrite Property

C1ZStreamWriter.CanWrite Property

Always returns True.

[Visual Basic]

Overrides Public ReadOnly Property CanWrite As Boolean

[C#]

override public bool CanWrite {get;}

[Delphi]

public property CanWrite: Boolean read get_CanWrite;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter.Checksum Property

C1ZStreamWriter.Checksum Property

Gets the checksum value used to check the integrity of the stream.

[Visual Basic]

Public ReadOnly Property Checksum As Integer

[C#]

public int Checksum {get;}

[Delphi]

public property Checksum: Int32 read get_Checksum;

Remarks

The checksum used may be an adler or crc32 value depending on how the C1ZStreamWriter was created.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter.Length Property

C1ZStreamWriter.Length Property

Returns the length of the underlying stream, in bytes.

[Visual Basic]

Overrides Public ReadOnly Property Length As Long

[C#]

override public long Length {get;}

[Delphi]

public property Length: Int64 read get_Length;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter.OwnsBaseStream Property

C1ZStreamWriter.OwnsBaseStream Property

Gets or sets whether calling the Close method will also close the underlying stream (see BaseStream).

[Visual Basic]

Public Property OwnsBaseStream As Boolean

[C#]

public bool OwnsBaseStream {get;set;}

[Delphi]

public property OwnsBaseStream: Boolean read get_OwnsBaseStream write set_OwnsBaseStream;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter.Position Property

C1ZStreamWriter.Position Property

Gets the position within the stream (read-only).

[Visual Basic]

Overrides Public Property Position As Long

[C#]

override public long Position {get;set;}

[Delphi]

public property Position: Int64 read get_Position write set_Position;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter.SizeCompressed Property

C1ZStreamWriter.SizeCompressed Property

Gets the number of bytes in the stream (compressed bytes).

[Visual Basic]

Public ReadOnly Property SizeCompressed As Integer

[C#]

public int SizeCompressed {get;}

[Delphi]

public property SizeCompressed: Int32 read get_SizeCompressed;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter.SizeUncompressed Property

C1ZStreamWriter.SizeUncompressed Property

Gets the number of bytes that were compressed into the stream (uncompressed bytes).

[Visual Basic]

Public ReadOnly Property SizeUncompressed As Integer

[C#]

public int SizeUncompressed {get;}

[Delphi]

public property SizeUncompressed: Int32 read get_SizeUncompressed;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter.ZStream Property

C1ZStreamWriter.ZStream Property

Gets the ZStream instance wrapped by this C1ZStreamWriter.

[Visual Basic]

Public ReadOnly Property ZStream As ZStream

[C#]

public ZStream ZStream {get;}

[Delphi]

public property ZStream: ZStream read get_ZStream;

Remarks

This property is useful only in advanced applications that need to customize the low-level behavior of the compressor. It is not needed in common appications.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter Methods

C1ZStreamWriter Methods

The methods of the C1ZStreamWriter class are listed here. For a complete list of C1ZStreamWriter class members, see the C1ZStreamWriter Members topic.

Public Methods

Close

Overriden. Closes the current stream compressor and flushed any pending data into the base stream.

If the OwnsBaseStream property is set to True (the default value), then this method also closes the base stream and releases any resources (such as sockets and file handles) associated with it.

Flush

Overriden. Clears all buffers for this stream and causes any buffered data to be written to the underlying stream.

Read

Overriden. Not supported.

Seek

Overriden. Not supported.

SetLength

Overriden. Not supported.

Write

Overriden. Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

WriteByte

Overriden. Writes a byte to the current position in the stream and advances the position within the stream by one byte.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter.Close Method

C1ZStreamWriter.Close Method

Closes the current stream compressor and flushed any pending data into the base stream.

If the OwnsBaseStream property is set to True (the default value), then this method also closes the base stream and releases any resources (such as sockets and file handles) associated with it.

[Visual Basic]

Overrides Public Sub Close()

[C#]

override public void Close()

[Delphi]

public procedure Close(); override;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter.Flush Method

C1ZStreamWriter.Flush Method

Clears all buffers for this stream and causes any buffered data to be written to the underlying stream.

[Visual Basic]

Overrides Public Sub Flush()

[C#]

override public void Flush()

[Delphi]

public procedure Flush(); override;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter.Read Method

C1ZStreamWriter.Read Method

Not supported.

[Visual Basic]

Overrides Public Function Read( _

ByVal buf As Byte(), _

ByVal offset As Integer, _

ByVal count As Integer _

) As Integer

[C#]

override public int Read(

Byte[] buf,

int offset,

int count

);

[Delphi]

public function Read(

buf: array of Byte;

offset: Int32;

count: Int32

): Int32; override;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter.Seek Method

C1ZStreamWriter.Seek Method

Not supported.

[Visual Basic]

Overrides Public Function Seek( _

ByVal offset As Long, _

ByVal origin As SeekOrigin _

) As Long

[C#]

override public long Seek(

long offset,

SeekOrigin origin

);

[Delphi]

public function Seek(

offset: Int64;

origin: SeekOrigin

): Int64; override;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter.SetLength Method

C1ZStreamWriter.SetLength Method

Not supported.

[Visual Basic]

Overrides Public Sub SetLength( _

ByVal value As Long _

)

[C#]

override public void SetLength(

long value

);

[Delphi]

public procedure SetLength(

value: Int64

); override;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter.Write Method

C1ZStreamWriter.Write Method

Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

[Visual Basic]

Overrides Public Sub Write( _

ByVal buf As Byte(), _

ByVal offset As Integer, _

ByVal count As Integer _

)

[C#]

override public void Write(

Byte[] buf,

int offset,

int count

);

[Delphi]

public procedure Write(

buf: array of Byte;

offset: Int32;

count: Int32

); override;

Parameters

buf

An array of bytes. This method copies count bytes from

buf to the current stream.

offset

The zero-based byte offset in buf at which to begin copying bytes to the current stream.

count

The number of bytes to be written to the current stream.

Remarks

The data is compressed as it is written into the stream. Writing count bytes into the stream will usually advance the position by a number smaller than count .

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1ZStreamWriter.WriteByte Method

C1ZStreamWriter.WriteByte Method

Writes a byte to the current position in the stream and advances the position within the stream by one byte.

[Visual Basic]

Overrides Public Sub WriteByte( _

ByVal value As Byte _

)

[C#]

override public void WriteByte(

Byte value

);

[Delphi]

public procedure WriteByte(

value: Byte

); override;

Parameters

value

Value to be written to the stream.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


CompressionLevelEnum Enumeration

CompressionLevelEnum Enumeration

Specifies the level of compression to be applied when adding entries to a C1ZipFile.

[Visual Basic]

Public Enum CompressionLevelEnum

[C#]

public enum CompressionLevelEnum

[Delphi]

type CompressionLevelEnum = (BestCompression, BestSpeed, DefaultCompression, NoCompression);

Namespace: C1.C1Zip

Assembly: C1.C1Zip (in c1.c1zip.dll)

Members

Member name | Description
BestCompression | Highest compression, low speed.
BestSpeed | Low compression, highest speed.
DefaultCompression | High compression, high speed.
NoCompression | No Compression.

See Also

C1.C1Zip Namespace

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZipProgressEventArgs Class

ZipProgressEventArgs Class

Provides data for the C1.C1Zip.C1ZipFile.Progress event of a C1ZipFile.

For a list of all members of this type, see ZipProgressEventArgs Members.

System.Object

System.EventArgs

C1.C1Zip.ZipProgressEventArgs

[Visual Basic]

Public Class ZipProgressEventArgs

Inherits EventArgs

[C#]

public class ZipProgressEventArgs : EventArgs

[Delphi]

type ZipProgressEventArgs = class(EventArgs);(EventArgs);

Namespace: C1.C1Zip

Assembly: C1.C1Zip (in c1.c1zip.dll)

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZipProgressEventArgs Members

ZipProgressEventArgs Members

ZipProgressEventArgs overview

Public Fields

Cancel | Set to True to cancel the current operation.
FileLength | Gets the length of the file being compressed or expanded.
FileName | Gets the name of the file being compressed or expanded.

Public Properties

Position

Gets the current position into the stream.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZipProgressEventArgs Fields

ZipProgressEventArgs Fields

The fields of the ZipProgressEventArgs class are listed here. For a complete list of ZipProgressEventArgs class members, see the ZipProgressEventArgs Members topic.

Public Fields

Cancel | Set to True to cancel the current operation.
FileLength | Gets the length of the file being compressed or expanded.
FileName | Gets the name of the file being compressed or expanded.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZipProgressEventArgs.Cancel Field

ZipProgressEventArgs.Cancel Field

Set to True to cancel the current operation.

[Visual Basic]

Public Cancel As Boolean

[C#]

public bool Cancel

[Delphi]

public Cancel: Boolean;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZipProgressEventArgs.FileLength Field

ZipProgressEventArgs.FileLength Field

Gets the length of the file being compressed or expanded.

[Visual Basic]

Public ReadOnly FileLength As Integer

[C#]

public readonly int FileLength

[Delphi]

public FileLength: Int32;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZipProgressEventArgs.FileName Field

ZipProgressEventArgs.FileName Field

Gets the name of the file being compressed or expanded.

[Visual Basic]

Public ReadOnly FileName As String

[C#]

public readonly string FileName

[Delphi]

public FileName: String;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZipProgressEventArgs Properties

ZipProgressEventArgs Properties

The properties of the ZipProgressEventArgs class are listed here. For a complete list of ZipProgressEventArgs class members, see the ZipProgressEventArgs Members topic.

Public Properties

Position

Gets the current position into the stream.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZipProgressEventArgs.Position Property

ZipProgressEventArgs.Position Property

Gets the current position into the stream.

[Visual Basic]

Public ReadOnly Property Position As Integer

[C#]

public int Position {get;}

[Delphi]

public property Position: Int32 read get_Position;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZipProgressEventHandler Delegate

ZipProgressEventHandler Delegate

Represents the method that will handle the C1.C1Zip.C1ZipFile.Progress event of a C1ZipFile.

[Visual Basic]

Public Delegate Sub ZipProgressEventHandler( _

ByVal sender As Object, _

ByVal e As ZipProgressEventArgs _

)

[C#]

public delegate void ZipProgressEventHandler(

object sender,

ZipProgressEventArgs e

);

[Delphi]

type ZipProgressEventHandler = procedure (

sender: Object;

e: ZipProgressEventArgs

) of object;

Namespace: C1.C1Zip

Assembly: C1.C1Zip (in c1.c1zip.dll)

See Also

C1.C1Zip Namespace

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1.C1Zip.ZLib Namespace

C1.C1Zip.ZLib Namespace

C1.C1Zip.ZLib Hierarchy

Classes

Class | Description
ZStream | ZStream is the most flexible and hardest to use class in the C1.C1Zip assembly. It contains a C# implementation of ZLIB's zstream object, which is a general purpose compressor and decompressor.
ZStreamException | ZStreamException

See Also

C1.C1Zip Assembly

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream Class

ZStream Class

ZStream is the most flexible and hardest to use class in the C1.C1Zip assembly. It contains a C# implementation of ZLIB's zstream object, which is a general purpose compressor and decompressor.

For a list of all members of this type, see ZStream Members.

System.Object

C1.C1Zip.ZLib.ZStream

[Visual Basic]

Public Class ZStream

[C#]

public class ZStream

[Delphi]

type ZStream = class

Remarks

In most cases, you should be able to use the C1ZStreamReader and C1ZStreamWriter classes instead of ZStream . These classes provide friendly and easy-to-use wrappers that hide the ZLIB complexity.

Use ZStream only if you are familiar with ZLIB and need control over the low-level aspects of the data compression or decompression process (e.g., to provide your own buffers or compression dictionaries).

If you choose to use ZStream directly and need technical support, please check out the detailed documentation, sample, and articles available at http://www.info-zip.org/ or http://www.gzip.org/, the official zlib sites.

ZLIB is an open-source, patent-free library created by Jean-loup Gailly and Mark Adler.

Namespace: C1.C1Zip.ZLib

Assembly: C1.C1Zip (in c1.c1zip.dll)

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream Members

ZStream Members

ZStream overview

Public Constructors

ZStream Constructor

Initializes a new instance of the ZStream class using an Adler checksum.

Public Fields

adler | Current checksum value (Adler or CRC32).
avail_in | Number of bytes available in the input buffer.
avail_out | Number of free bytes remaining in output buffer.
msg | Description of the last error (null if no errors).
next_in | Input buffer.
next_in_index | Position of cursor into input buffer.
next_out | Output buffer.
next_out_index | Position of cursor into output buffer.
total_in | Total number of input bytes read so far.
total_out | Total number of bytes output so far.
Z_BUF_ERROR | No progress possible or no room in output buffer.
Z_DATA_ERROR | Input data is corrupted (wrong format or checksum).
Z_ERRNO | File error.
Z_MEM_ERROR | Not enough memory.
Z_NEED_DICT | A preset dictionary is needed at this point.
Z_OK | No error.
Z_STREAM_END | End of stream detected.
Z_STREAM_ERROR | Stream structure is inconsistent (input/output buffers are null for example).
Z_VERSION_ERROR | Incompatible ZLIB version.

Public Methods

deflate | Compresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full.
deflateEnd | Frees all dynamically allocated data structures for this stream, discards any unprocessed input, and does not flush any pending output.
deflateInit | Overloaded. Initializes the internal stream state for compression.
deflateParams | Dynamically updates the compression level and compression strategy.
deflateSetDictionary | Initializes the compression dictionary from the given byte sequence without producing any compressed output.
inflate | Decompresses as much data as possible until the input buffer is exhausted or the output buffer is full.
inflateEnd | Frees all dynamically allocated data structures for this stream, discards any unprocessed input, and does not flush any pending output.
inflateInit | Overloaded. Initializes the internal stream state for decompression.
inflateSetDictionary | Initializes the decompression dictionary from the given uncompressed byte sequence.
inflateSync | Skips invalid compressed data until a full flush point is found, or until all available input is skipped. No output is provided.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream Constructor

ZStream Constructor

Overload List

Initializes a new instance of the ZStream class using an Adler checksum.

[Visual Basic] Public Function New()

[C#] public ZStream();

[Delphi] public constructor Create(); overload;

Initializes a new instance of the ZStream class.

[Visual Basic] Public Function New(Boolean)

[C#] public ZStream(bool);

[Delphi] public constructor Create(Boolean); overload;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream Constructor ()

ZStream Constructor ()

Initializes a new instance of the ZStream class using an Adler checksum.

[Visual Basic]

Public Function New()

[C#]

public ZStream()

[Delphi]

public constructor Create(); overload;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream Constructor (Boolean)

ZStream Constructor (Boolean)

Initializes a new instance of the ZStream class.

[Visual Basic]

Public Function New( _

ByVal crc32 As Boolean _

)

[C#]

public ZStream(

bool crc32

);

[Delphi]

public constructor Create(

crc32: Boolean

); overload;

Parameters

crc32

True to use a CRC32 checksum, False to use an Adler checksum.

Remarks

CRC32 checksums are the standard used in zip files. Adler checksums are the default used by ZLIB. Adler checksums are faster to calculate, but are not compatible with the zip format.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream Fields

ZStream Fields

The fields of the ZStream class are listed here. For a complete list of ZStream class members, see the ZStream Members topic.

Public Fields

adler | Current checksum value (Adler or CRC32).
avail_in | Number of bytes available in the input buffer.
avail_out | Number of free bytes remaining in output buffer.
msg | Description of the last error (null if no errors).
next_in | Input buffer.
next_in_index | Position of cursor into input buffer.
next_out | Output buffer.
next_out_index | Position of cursor into output buffer.
total_in | Total number of input bytes read so far.
total_out | Total number of bytes output so far.
Z_BUF_ERROR | No progress possible or no room in output buffer.
Z_DATA_ERROR | Input data is corrupted (wrong format or checksum).
Z_ERRNO | File error.
Z_MEM_ERROR | Not enough memory.
Z_NEED_DICT | A preset dictionary is needed at this point.
Z_OK | No error.
Z_STREAM_END | End of stream detected.
Z_STREAM_ERROR | Stream structure is inconsistent (input/output buffers are null for example).
Z_VERSION_ERROR | Incompatible ZLIB version.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.adler Field

ZStream.adler Field

Current checksum value (Adler or CRC32).

[Visual Basic]

Public adler As Long

[C#]

public long adler

[Delphi]

public adler: Int64;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.avail_in Field

ZStream.avail_in Field

Number of bytes available in the input buffer.

[Visual Basic]

Public avail_in As Integer

[C#]

public int avail_in

[Delphi]

public avail_in: Int32;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.avail_out Field

ZStream.avail_out Field

Number of free bytes remaining in output buffer.

[Visual Basic]

Public avail_out As Integer

[C#]

public int avail_out

[Delphi]

public avail_out: Int32;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.msg Field

ZStream.msg Field

Description of the last error (null if no errors).

[Visual Basic]

Public msg As String

[C#]

public string msg

[Delphi]

public msg: String;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.next_in Field

ZStream.next_in Field

Input buffer.

[Visual Basic]

Public next_in As Byte()

[C#]

public Byte[] next_in

[Delphi]

public next_in: array of Byte;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.next_in_index Field

ZStream.next_in_index Field

Position of cursor into input buffer.

[Visual Basic]

Public next_in_index As Integer

[C#]

public int next_in_index

[Delphi]

public next_in_index: Int32;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.next_out Field

ZStream.next_out Field

Output buffer.

[Visual Basic]

Public next_out As Byte()

[C#]

public Byte[] next_out

[Delphi]

public next_out: array of Byte;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.next_out_index Field

ZStream.next_out_index Field

Position of cursor into output buffer.

[Visual Basic]

Public next_out_index As Integer

[C#]

public int next_out_index

[Delphi]

public next_out_index: Int32;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.total_in Field

ZStream.total_in Field

Total number of input bytes read so far.

[Visual Basic]

Public total_in As Long

[C#]

public long total_in

[Delphi]

public total_in: Int64;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.total_out Field

ZStream.total_out Field

Total number of bytes output so far.

[Visual Basic]

Public total_out As Long

[C#]

public long total_out

[Delphi]

public total_out: Int64;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.Z_BUF_ERROR Field

ZStream.Z_BUF_ERROR Field

No progress possible or no room in output buffer.

[Visual Basic]

Public Const Shared Z_BUF_ERROR As Integer

[C#]

public const static int Z_BUF_ERROR

[Delphi]

public const Z_BUF_ERROR = Int32(-5);

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.Z_DATA_ERROR Field

ZStream.Z_DATA_ERROR Field

Input data is corrupted (wrong format or checksum).

[Visual Basic]

Public Const Shared Z_DATA_ERROR As Integer

[C#]

public const static int Z_DATA_ERROR

[Delphi]

public const Z_DATA_ERROR = Int32(-3);

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.Z_ERRNO Field

ZStream.Z_ERRNO Field

File error.

[Visual Basic]

Public Const Shared Z_ERRNO As Integer

[C#]

public const static int Z_ERRNO

[Delphi]

public const Z_ERRNO = Int32(-1);

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.Z_MEM_ERROR Field

ZStream.Z_MEM_ERROR Field

Not enough memory.

[Visual Basic]

Public Const Shared Z_MEM_ERROR As Integer

[C#]

public const static int Z_MEM_ERROR

[Delphi]

public const Z_MEM_ERROR = Int32(-4);

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.Z_NEED_DICT Field

ZStream.Z_NEED_DICT Field

A preset dictionary is needed at this point.

[Visual Basic]

Public Const Shared Z_NEED_DICT As Integer

[C#]

public const static int Z_NEED_DICT

[Delphi]

public const Z_NEED_DICT = Int32(2);

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.Z_OK Field

ZStream.Z_OK Field

No error.

[Visual Basic]

Public Const Shared Z_OK As Integer

[C#]

public const static int Z_OK

[Delphi]

public const Z_OK = Int32(0);

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.Z_STREAM_END Field

ZStream.Z_STREAM_END Field

End of stream detected.

[Visual Basic]

Public Const Shared Z_STREAM_END As Integer

[C#]

public const static int Z_STREAM_END

[Delphi]

public const Z_STREAM_END = Int32(1);

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.Z_STREAM_ERROR Field

ZStream.Z_STREAM_ERROR Field

Stream structure is inconsistent (input/output buffers are null for example).

[Visual Basic]

Public Const Shared Z_STREAM_ERROR As Integer

[C#]

public const static int Z_STREAM_ERROR

[Delphi]

public const Z_STREAM_ERROR = Int32(-2);

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.Z_VERSION_ERROR Field

ZStream.Z_VERSION_ERROR Field

Incompatible ZLIB version.

[Visual Basic]

Public Const Shared Z_VERSION_ERROR As Integer

[C#]

public const static int Z_VERSION_ERROR

[Delphi]

public const Z_VERSION_ERROR = Int32(-6);

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream Methods

ZStream Methods

The methods of the ZStream class are listed here. For a complete list of ZStream class members, see the ZStream Members topic.

Public Methods

deflate | Compresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full.
deflateEnd | Frees all dynamically allocated data structures for this stream, discards any unprocessed input, and does not flush any pending output.
deflateInit | Overloaded. Initializes the internal stream state for compression.
deflateParams | Dynamically updates the compression level and compression strategy.
deflateSetDictionary | Initializes the compression dictionary from the given byte sequence without producing any compressed output.
inflate | Decompresses as much data as possible until the input buffer is exhausted or the output buffer is full.
inflateEnd | Frees all dynamically allocated data structures for this stream, discards any unprocessed input, and does not flush any pending output.
inflateInit | Overloaded. Initializes the internal stream state for decompression.
inflateSetDictionary | Initializes the decompression dictionary from the given uncompressed byte sequence.
inflateSync | Skips invalid compressed data until a full flush point is found, or until all available input is skipped. No output is provided.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.deflate Method

ZStream.deflate Method

Compresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full.

[Visual Basic]

Public Function deflate( _

ByVal flush As Integer _

) As Integer

[C#]

public int deflate(

int flush

);

[Delphi]

public function deflate(

flush: Int32

): Int32;

Parameters

flush

Non-zero to force some data to be flushed into the output buffer.

Return Value

Zero on success, an error code on failure.

Remarks

deflate performs one or both of the following actions:

1. Compress more input starting at next_in and update next_in and avail_in accordingly. If not all input can be processed (because there is not enough room in the output buffer), next_in and avail_in are updated and processing will resume at this point for the next call to deflate .

2. Provide more output starting at next_out and update next_out and avail_out accordingly. This action is forced if the parameter flush is non zero. Forcing flush frequently degrades the compression ratio, so this parameter should be set only when necessary (in interactive applications). Some output may be provided even if flush is not set

This method may introduce some output latency (reading input without producing any output) except when forced to flush.

If deflate returns with avail_out == 0, this method must be called again with the same value of the flush parameter and more output space until the flush is complete ( deflate returns with avail_out != 0).

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.deflateEnd Method

ZStream.deflateEnd Method

Frees all dynamically allocated data structures for this stream, discards any unprocessed input, and does not flush any pending output.

[Visual Basic]

Public Function deflateEnd() As Integer

[C#]

public int deflateEnd()

[Delphi]

public function deflateEnd(): Int32;

Return Value

Zero on success, an error code on failure.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.deflateInit Method

ZStream.deflateInit Method

Overload List

Initializes the internal stream state for compression.

[Visual Basic] Overloads Public Function deflateInit(Integer) As Integer

[C#] public int deflateInit(int);

[Delphi] public function deflateInit(Int32) : Int32; overload;

Initializes the internal stream state for compression.

[Visual Basic] Overloads Public Function deflateInit(Integer, Integer) As Integer

[C#] public int deflateInit(int, int);

[Delphi] public function deflateInit(Int32; Int32) : Int32; overload;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.deflateInit Method (Int32)

ZStream.deflateInit Method (Int32)

Initializes the internal stream state for compression.

[Visual Basic]

Overloads Public Function deflateInit( _

ByVal level As Integer _

) As Integer

[C#]

public int deflateInit(

int level

);

[Delphi]

public function deflateInit(

level: Int32

): Int32; overload;

Parameters

level

Compression level between zero and nine (0-9).

Return Value

Zero on success, an error code on failure.

Remarks

Compression level 1 gives best speed, 9 gives best compression.

Compression level zero gives no compression at all (the input data is simply copied a block at a time).

The default compression level is 6, which provides a compromise between speed and compression.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.deflateInit Method (Int32, Int32)

ZStream.deflateInit Method (Int32, Int32)

Initializes the internal stream state for compression.

[Visual Basic]

Overloads Public Function deflateInit( _

ByVal level As Integer, _

ByVal bits As Integer _

) As Integer

[C#]

public int deflateInit(

int level,

int bits

);

[Delphi]

public function deflateInit(

level: Int32;

bits: Int32

): Int32; overload;

Parameters

level

Compression level between zero and nine (0-9).

bits

Size of the LZ77 sliding compression window in bits (the default value is 15 bits).

Return Value

Zero on success, an error code on failure.

Remarks

Compression level 1 gives best speed, 9 gives best compression.

Compression level zero gives no compression at all (the input data is simply copied a block at a time).

The default compression level is 6, which provides a compromise between speed and compression.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.deflateParams Method

ZStream.deflateParams Method

Dynamically updates the compression level and compression strategy.

[Visual Basic]

Public Function deflateParams( _

ByVal level As Integer, _

ByVal strategy As Integer _

) As Integer

[C#]

public int deflateParams(

int level,

int strategy

);

[Delphi]

public function deflateParams(

level: Int32;

strategy: Int32

): Int32;

Parameters

level

Compression level between zero and nine (0-9).

strategy

Compression strategy (0-2).

Return Value

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.deflateSetDictionary Method

ZStream.deflateSetDictionary Method

Initializes the compression dictionary from the given byte sequence without producing any compressed output.

[Visual Basic]

Public Function deflateSetDictionary( _

ByVal dictionary As Byte(), _

ByVal dictLength As Integer _

) As Integer

[C#]

public int deflateSetDictionary(

Byte[] dictionary,

int dictLength

);

[Delphi]

public function deflateSetDictionary(

dictionary: array of Byte;

dictLength: Int32

): Int32;

Parameters

dictionary

Data in the dictionary.

dictLength

Number of bytes in the ditionary.

Return Value

Zero on success, an error code on failure.

Remarks

This method must be called immediately after deflateInit (Int32), before any call to deflate.

The compressor and decompressor must use exactly the same dictionary (see inflateSetDictionary).

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.inflate Method

ZStream.inflate Method

Decompresses as much data as possible until the input buffer is exhausted or the output buffer is full.

[Visual Basic]

Public Function inflate( _

ByVal flush As Integer _

) As Integer

[C#]

public int inflate(

int flush

);

[Delphi]

public function inflate(

flush: Int32

): Int32;

Parameters

flush

How to flush data into output buffer (default value is 2).

Return Value

Z_OK if some progress has been made (more input processed or more output produced), Z_STREAM_END if the end of the compressed data has been reached and all uncompressed output has been produced, Z_NEED_DICT if a preset dictionary is needed at this point, Z_DATA_ERROR if the input data was corrupted (input stream not conforming to the zlib format or incorrect checksum), Z_STREAM_ERROR if the stream structure was inconsistent (for example if next_in or next_out was null), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if no progress is possible or if there was not enough room in the output buffer when Z_FINISH is used.

Remarks

inflate performs one or both of the following actions:

1. Decompress more input starting at next_in and update next_in and avail_in accordingly. If not all input can be processed (because there is not enough room in the output buffer), next_in is updated and processing will resume at this point for the next call to inflate.

2. Provide more output starting at next_out and update next_out and avail_out accordingly. inflate provides as much output as possible, until there is no more input data or no more space in the output buffer.

Before the call to inflate, the application should ensure that at least one of the actions is possible, by providing more input and/or consuming more output, and updating the next_* and avail_* values accordingly.

If inflate returns Zero and avail_out == 0, it must be called again after making room in the output buffer because there might be more output pending.

The application can consume the uncompressed output when it wants, for example when the output buffer is full ( avail_out == 0), or after each call of inflate .

This method may introduce some output latency (reading input without producing any output) except when forced to flush.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.inflateEnd Method

ZStream.inflateEnd Method

Frees all dynamically allocated data structures for this stream, discards any unprocessed input, and does not flush any pending output.

[Visual Basic]

Public Function inflateEnd() As Integer

[C#]

public int inflateEnd()

[Delphi]

public function inflateEnd(): Int32;

Return Value

Zero on success, an error code on failure.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.inflateInit Method

ZStream.inflateInit Method

Overload List

Initializes the internal stream state for decompression.

[Visual Basic] Overloads Public Function inflateInit() As Integer

[C#] public int inflateInit();

[Delphi] public function inflateInit() : Int32; overload;

Initializes the internal stream state for decompression.

[Visual Basic] Overloads Public Function inflateInit(Integer) As Integer

[C#] public int inflateInit(int);

[Delphi] public function inflateInit(Int32) : Int32; overload;

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.inflateInit Method ()

ZStream.inflateInit Method ()

Initializes the internal stream state for decompression.

[Visual Basic]

Overloads Public Function inflateInit() As Integer

[C#]

public int inflateInit()

[Delphi]

public function inflateInit(): Int32; overload;

Return Value

Zero on success, an error code on failure.

Remarks

The fields next_in and avail_in must be initialized before by the caller.

inflateInit does not perform any decompression apart from reading the zlib header if present: data decompression is done by the inflate method. Therefore, the next_in and avail_in may be modified, but next_out and avail_out are unchanged.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.inflateInit Method (Int32)

ZStream.inflateInit Method (Int32)

Initializes the internal stream state for decompression.

[Visual Basic]

Overloads Public Function inflateInit( _

ByVal bits As Integer _

) As Integer

[C#]

public int inflateInit(

int bits

);

[Delphi]

public function inflateInit(

bits: Int32

): Int32; overload;

Parameters

bits

Size of the LZ77 sliding compression window in bits (the default value is 15 bits).

Return Value

Zero on success, an error code on failure.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.inflateSetDictionary Method

ZStream.inflateSetDictionary Method

Initializes the decompression dictionary from the given uncompressed byte sequence.

[Visual Basic]

Public Function inflateSetDictionary( _

ByVal dictionary As Byte(), _

ByVal dictLength As Integer _

) As Integer

[C#]

public int inflateSetDictionary(

Byte[] dictionary,

int dictLength

);

[Delphi]

public function inflateSetDictionary(

dictionary: array of Byte;

dictLength: Int32

): Int32;

Parameters

dictionary

Data in the dictionary.

dictLength

Number of bytes in the ditionary.

Return Value

Zero on success, an error code on failure.

Remarks

This method must be called immediately after a call of inflate if this call returned Z_NEED_DICT . The dictionary chosen by the compressor can be determined from the Adler32 value returned by this call to inflate .

The compressor and decompressor must use exactly the same dictionary (see the deflateSetDictionary method).

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStream.inflateSync Method

ZStream.inflateSync Method

Skips invalid compressed data until a full flush point is found, or until all available input is skipped. No output is provided.

[Visual Basic]

Public Function inflateSync() As Integer

[C#]

public int inflateSync()

[Delphi]

public function inflateSync(): Int32;

Return Value

Zero on success, an error code on failure.

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStreamException Class

ZStreamException Class

ZStreamException

For a list of all members of this type, see ZStreamException Members.

System.Object

System.Exception

System.ApplicationException

C1.C1Zip.ZLib.ZStreamException

[Visual Basic]

Public Class ZStreamException

Inherits ApplicationException

[C#]

public class ZStreamException : ApplicationException

[Delphi]

type ZStreamException = class(ApplicationException);(ApplicationException);

Namespace: C1.C1Zip.ZLib

Assembly: C1.C1Zip (in c1.c1zip.dll)

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


ZStreamException Members

ZStreamException Members

ZStreamException overview

See Also

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


Adding a Reference to C1Zip Assembly - C#

C#

using System.IO;

using C1.C1Zip;


Adding a Reference to C1Zip Assembly - Delphi

Delphi

uses System.IO, C1.C1Zip;


Adding a Reference to C1Zip Assembly - Visual Basic

Visual Basic

Imports System.IO

Imports C1.C1Zip


C1.C1Zip Hierarchy

C1.C1Zip Hierarchy

System.Object

System.MarshalByRefObject

System.IO.Stream

C1.C1Zip.C1ZStreamReader

C1.C1Zip.C1ZStreamWriter

C1.C1Zip.C1ZipEntry

C1.C1Zip.C1ZipEntryCollection ---- System.Collections.ICollection, System.Collections.IEnumerable

C1.C1Zip.C1ZipFile ---- System.IDisposable

System.EventArgs

C1.C1Zip.ZipProgressEventArgs

System.ValueType

System.Enum

C1.C1Zip.CompressionLevelEnum

System.Delegate

System.MulticastDelegate

C1.C1Zip.ZipProgressEventHandler

See Also

C1.C1Zip Namespace

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1.C1Zip.ZLib Hierarchy

C1.C1Zip.ZLib Hierarchy

System.Object

C1.C1Zip.ZLib.ZStream

System.Exception

System.ApplicationException

C1.C1Zip.ZLib.ZStreamException

See Also

C1.C1Zip.ZLib Namespace

Untitled Document
Send feedback to ComponentOne
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.


C1Zip Add Files - C#

C#

private void btnAdd_Click(object sender, EventArgs e)

{

// get list of files to add

OpenFileDialog OpenFileDialog fo = new OpenFileDialog();

fo.Multiselect = true;

fo.FileName = "*.*";

if (fo.ShowDialog != DialogResult.OK) return;

// add files in the list

foreach (string file In fo.FileNames())

{

m_Zip.Entries.Add(file);

}

// done

UpdateDisplay();

}


C1Zip Add Files - Delphi

Delphi

procedure btnAdd_Click(sender: Object; e: EventArgs);

var

fo: OpenFileDialog;

fl: string;

begin

// get list of files to add

fo := OpenFileDialog.Create;

fo.Multiselect := True;

fo.FileName := '*.*';

if fo.ShowDialog <> System.Windows.Forms.DialogResult.OK then exit;

// add files in the list

for i := 0 to fo.FileNames.Length - 1 do

m_Zip.Entries.Add(fo.FileNames[i]);

// done

UpdateDisplay;

end;


C1Zip Add Files to a Zip Archive and Specify Path - C#

C#

foreach (string fileName in Directory.GetFiles(@"c:\"))

{

try

{

string fileTitle = Path.GetFileName(fileName);

_zipFile.Entries.Add(fname, @"mydir\myfiles\" + fileTitle);

}

catch {}

}


C1Zip Add Files to a Zip Archive and Specify Path - Delphi

Delphi

var

fileTitle: string;

begin

try

fileTitle := Path.GetFileName(fileName);

_zipFile.Entries.Add(fname, ('mydir\myfiles\' + fileTitle));

except

on : System.Exception do

end;

end;


C1Zip Add Files to a Zip Archive and Specify Path - Visual Basic

Visual Basic

Dim fileName As String

For Each fileName In Directory.GetFiles("c:\")

Try

Dim fileTitle As String = Path.GetFileName(fileName)

_zipFile.Entries.Add(fname, "mydir\myfiles\" & fileTitle)

Catch

End Try

End If


C1Zip Add Files - Visual Basic

Visual Basic

Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click

' get list of files to add

Dim fo As OpenFileDialog = New OpenFileDialog()

fo.Multiselect = True

fo.FileName = "*.*"

If fo.ShowDialog <> DialogResult.OK Then Exit Sub

' add files in the list

Dim file As String

For Each file In fo.FileNames()

m_Zip.Entries.Add(file)

Next

' done

UpdateDisplay()

End Sub


C1Zip Adding a Reference2 - C#

C#

using System.IO;

using C1.C1Zip;


C1Zip Adding a Reference2 - Delphi

Delphi

Uses System.IO, C1.C1Zip;


C1Zip Adding a Reference2 - Visual Basic

Visual Basic

Imports System.IO

Imports C1.C1Zip


C1Zip Adding a Reference4 - C#

C#

using System.IO;

using C1. C1Zip;


C1Zip Adding a Reference4 - Delphi

Delphi

uses System.IO, C1. C1Zip;


C1Zip Adding a Reference4 - Visual Basic

Visual Basic

Imports System.IO

Imports C1. C1Zip


C1Zip Adding References - C#

C#

using System.IO;

using C1.C1Zip;


C1Zip Adding References - Delphi

Delphi

uses

System.I0, C1.C1Zip;

begin

end;


C1Zip Adding References - Visual Basic

Visual Basic

Imports System.IO

Imports C1.C1Zip


C1Zip AddReferences3 - C#

C#

using System.IO;

using System.Data.OleDb;

using System.Runtime.Serialization.Formatters.Binary;

using C1.C1Zip;


C1Zip AddReferences3 - Delphi

Delphi

uses System.IO, System.Data.OleDb, System.Runtime.Serialization.Formatters.Binary, C1.C1Zip;


C1Zip AddReferences3 - Visual Basic

Visual Basic

Imports System.IO

Imports System.Data.OleDb

Imports System.Runtime.Serialization.Formatters.Binary

Imports C1.C1Zip


C1Zip Add String File Name - C#

C#

string fileName = @"c:\myfiles\myletters\joe.txt";

// store entry as 'joe.txt'

_zip.Entries.Add(fileName);

// store entry as 'c:\myfiles\myletters\joe.txt'

_zip.Entries.Add(fileName, fileName);


C1Zip Add String File Name - Delphi

Delphi

var

fileName: string;

begin

fileName := 'c:\myfiles\myletters\joe.txt';

// store entry as 'joe.txt'

_zip.Entries.Add(fileName);

// store entry as 'c:\myfiles\myletters\joe.txt'

_zip.Entries.Add(fileName, fileName);

end;


C1Zip Add String File Name - Visual Basic

Visual Basic

Dim fileName As String = "c:\myfiles\myletters\joe.txt"

' store entry as 'joe.txt'

_zip.Entries.Add(fileName)

' store entry as 'c:\myfiles\myletters\joe.txt'

_zip.Entries.Add(fileName, fileName)


C1Zip Check If Entries are Encrypted - C#

C#

foreach (C1ZipEntry ze In zip.Entries){

if (ze.IsEncrypted)

Debug.WriteLine(ze.FileName + " (encrypted)");

} else {

Debug.WriteLine(ze.FileName);

}

}


C1Zip Check If Entries are Encrypted - Delphi

Delphi

var

ze: C1ZipEntry;

begin

if ze.IsEncrypted then begin

Debug.WriteLine((ze.FileName + ' (encrypted)'));

else

Debug.WriteLine(ze.FileName);

end;


C1Zip Check If Entries are Encrypted - Visual Basic

Visual Basic

Dim ze As C1ZipEntry

For Each ze In zip.Entries

If ze.IsEncrypted Then

Debug.WriteLine(ze.FileName + " (encrypted)")

Else

Debug.WriteLine(ze.FileName)

End If

Next


C1ZipClass - C#

C#

// Define a new C1ZipFile object (custom C1ZipFile class)

C1ZipFile myZip = new C1ZipFile();

// Define a new C1Zip.C1ZipFile object.

C1.C1Zip.C1ZipFile myZip = new C1.C1Zip.C1ZipFile();


C1ZipClass - Delphi

Delphi

var

myZip: C1.C1Zip.C1ZipFile;

myZip: C1ZipFile;

begin

myZip := C1ZipFile.Create;

myZip := C1.C1Zip.C1ZipFile.Create;

end;


C1ZipClass - Visual Basic

Visual Basic

' Define a new C1ZipFile object (custom C1ZipFile class)

Dim MyC1ZipFile as C1ZipFile

' Define a new C1Zip.C1ZipFile object.

Dim ZipFile as C1.C1Zip.C1ZipFile


C1Zip Compress File Function - C#

C#

private bool CompressFile(string dstFile, string srcFile) {

// prepare to compress file

bool retval = true;

FileStream srcStream = null;

FileStream dstStream = null;

try

{

// open the files

srcStream = new FileStream(srcFile, FileMode.Open, FileAccess.Read);

dstStream = new FileStream(dstFile, FileMode.Create, FileAccess.Write);

// open compressor stream on destination file

C1ZStreamWriter sw = new C1ZStreamWriter(dstStream);

// copy source into compressor stream

StreamCopy(sw, srcStream);

}

catch // exception? tell caller we failed

{

retval = false;

}

finally // always close our streams

{

if (srcStream != null)) srcStream.Close();

if (dstStream != null)) dstStream.Close();

}

// done

return false;

}


C1Zip Compress File Function - Delphi

Delphi

function CompressFile(dstFile: String; srcFile: String): Boolean;

var

sw: C1ZStreamWriter;

dstStream: FileStream;

srcStream: FileStream;

retval: Boolean;

begin

retval := True;

srcStream := nil;

dstStream := nil;

try

srcStream := FileStream.Create(srcFile, FileMode.Open, FileAccess.Read);

dstStream := FileStream.Create(dstFile, FileMode.Create, FileAccess.Write);

sw := C1ZStreamWriter.Create(dstStream);

StreamCopy(sw, srcStream);

except

on : GAIS do

retval := False;

end;

end;


C1Zip Compress File Function - Visual Basic

Visual Basic

Private Function CompressFile(dstFile As String, srcFile As String) As Boolean

' prepare to compress file

Dim retval As Boolean = True

Dim srcStream As FileStream = Nothing

Dim dstStream As FileStream = Nothing

Try

' open the files

srcStream = New FileStream(srcFile, FileMode.Open, FileAccess.Read)

dstStream = New FileStream(dstFile, FileMode.Create, FileAccess.Write)

' open compressor stream on destination file

Dim sw As C1ZStreamWriter = _

New C1ZStreamWriter(dstStream)

' copy source into compressor stream

StreamCopy(sw, srcStream)

Catch ' exception? tell caller we failed

retval = False

Finally ' always close our streams

If Not (srcStream Is Nothing) Then srcStream.Close()

If Not (dstStream Is Nothing) Then dstStream.Close()

End Try

' done

CompressFile = False

End Function


C1Zip Compress Files - C#

C#

private void btnCompress_Click(System.object sender, System.EventArgs e)

{

// get application directory

string appPath = Application.ExecutablePath;

int i = appPath.IndexOf(@"\bin\");

if (i > 0) appPath = appPath.Substring(0, i);

// create directory for compressed files

if ((Directory.Exists(appPath + DIR_COMP)))

Directory.Delete(appPath + DIR_COMP, true);

Directory.CreateDirectory(appPath + DIR_COMP);

// prepare to collect compression statistics

long count = 0;

long size = 0;

long sizeCompressed = 0;

long ticks = DateTime.Now.Ticks;

// compress all files in application dir into compressed dir

(( string[] files = Directory.GetFiles(appPath);

foreach (string srcFile in files)

{

string dstFile = appPath + DIR_COMP + "\" +

Path.GetFileName(srcFile) + ".cmp";

// compress file

CompressFile(dstFile, srcFile);

// update stats

count++;

size += new FileInfo(srcFile).Length;

sizeCompressed += new FileInfo(dstFile).Length;

}

// show stats

string msg = string .Format(

"Compressed {0} files in {1} ms.\n\r" +

"Original size: {2:#,###}\n\r" +

"Compressed size: {3:#,###} ({4:0.00}% of original)",

count,

(DateTime.Now.Ticks - ticks) / TimeSpan.TicksPerMillisecond,

size,

sizeCompressed,

(sizeCompressed / size) * 100.0);

label1.Text = msg;

// now we can expand

btnExpand.Enabled = true;

}


C1Zip Compress Files - Delphi

Delphi

procedure TWinForm.btnCompress_Click(Sender: System.Object; e: System.EventArgs);

var

msg, path, dstFile: string;

files: array of string;

I: Integer;

fparams: array of TObject;

count, size, sizeCompressed: Integer;

ticks: Int64;

begin

// get application directory

path := System.IO.Path.GetDirectoryName(Application.ExecutablePath);

// create directory for compressed files

if Directory.Exists(path + DIR_COMP) then

Directory.Delete(path + DIR_COMP, True);

Directory.CreateDirectory(path + DIR_COMP);

// prepare to collect compression statistics

count := 0;

size := 0;

sizeCompressed := 0;

ticks := DateTime.Now.Ticks;

files := Directory.GetFiles(path);

for I := 0 to High(files) do

begin

if (System.String(files[I]).IndexOf('dcpil') = -1) then

begin

// compress file

dstFile := path + DIR_COMP + '\' + System.IO.Path.GetFileName(files[I]) + '.cmp';

CompressFile(dstFile, files[I]);

// update stats

Inc(count);

size := size + FileInfo.Create(files[I]).Length;

sizeCompressed := sizeCompressed + FileInfo.Create(dstFile).Length;

end;

end;

// show stats

SetLength(fparams, 5);

fparams[0] := System.Object(count);

fparams[1] := System.Object((DateTime.Now.Ticks - ticks) / TimeSpan.TicksPerMillisecond);

fparams[2] := System.Object(size);

fparams[3] := System.Object(sizeCompressed);

fparams[4] := System.Object(((sizeCompressed) / (size)) * 100.0);

msg := System.String.Format(

'Compressed {0} files in {1} ms.'#13#10 +

'Original size: {2:#,###}'#13#10 +

'Compressed size: {3:#,###} ({4:0.00}% of original)', fparams);

label1.Text := msg;

// now we can expand

btnExpand.Enabled := true;

end;


C1Zip Compress Files - Visual Basic

Visual Basic

Private Sub btnCompress_Click(ByVal sender As System.Object,

ByVal e As System.EventArgs) Handles btnCompress.Click

' get application directory

Dim appPath As String = Application.ExecutablePath

Dim i As Integer = appPath.IndexOf("\bin\")

If i > 0 Then appPath = appPath.Substring(0, i)

' create directory for compressed files

If (Directory.Exists(appPath + DIR_COMP)) Then

Directory.Delete(appPath + DIR_COMP, True)

End If

Directory.CreateDirectory(appPath + DIR_COMP)

' prepare to collect compression statistics

Dim count As Long

Dim size As Long

Dim sizeCompressed As Long

Dim ticks As Long = DateTime.Now.Ticks

' compress all files in application dir into compressed dir

Dim files As String() = Directory.GetFiles(appPath)

Dim srcFile As String

For Each srcFile In files

Dim dstFile As String

dstFile = appPath + DIR_COMP + "\" + Path.GetFileName(srcFile) + ".cmp"

' compress file

CompressFile(dstFile, srcFile)

' update stats

count = count + 1

size = size + New FileInfo(srcFile).Length

sizeCompressed = sizeCompressed + New FileInfo(dstFile).Length

Next

' show stats

Dim msg As String = String.Format(_

"Compressed {0} files in {1} ms." & vbCrLf & _

"Original size: {2:#,###}" & vbCrLf & _

"Compressed size: {3:#,###} ({4:0.00}% of original)", _

count, _

(DateTime.Now.Ticks - ticks) / TimeSpan.TicksPerMillisecond, _

size, _

sizeCompressed, (sizeCompressed / size) * 100.0)

label1.Text = msg

' now we can expand

btnExpand.Enabled = True

End Sub


C1Zip Compressing Binary Data - C#

C#

(private byte[] m_CompressedData;

private void btnCompressData_Click(System.object sender, System.EventArgs e)

{

// open memory stream

MemoryStream MemoryStream ms = new MemoryStream();

// attach compressor stream to memory stream

C1ZStreamWriter C1ZStreamWriter sw = new C1ZStreamWriter(ms);

// attach BinaryWriter to the compressor stream

BinaryWriter BinaryWriter bw = new BinaryWriter(sw);

// write a bunch of numbers into the stream

int i;

int count = 1000;

bw.Write(count);

for (i = 0 ; i <= count – 1

double a = i * Math.PI / 180.0;

bw.Write(i);

bw.Write(a);

bw.Write(Math.Sin(a));

bw.Write(Math.Cos(a));

}

// flush any pending output

bw.Flush();

// save the compressed data

m_CompressedData = ms.ToArray();

// done

string msg;

msg =string .Format("Generated table with {0} points," +

" saved into {1} bytes", count, m_CompressedData.Length);

label1.Text = msg;

// we can now expand it

btnExpandData.Enabled = true;

}


C1Zip Compressing Binary Data - Delphi

Delphi

procedure TWinForm.button4_Click(sender: System.Object; e: System.EventArgs);

var

ms: MemoryStream;

sw: C1ZStreamWriter;

bw: BinaryWriter;

I, count: Integer;

msg: string;

a: double;

begin

// open memory stream

ms := MemoryStream.Create;

// attach compressor stream to memory stream

sw := C1ZStreamWriter.Create(ms);

// attach BinaryWriter to the compressor stream

bw := BinaryWriter.Create(sw);

// write a bunch of numbers into the stream

count := 1000;

bw.Write(count);

for I := 0 to count - 1 do

begin

a := i * Math.PI / 180.0;

bw.Write(i);

bw.Write(a);

bw.Write(Math.Sin(a));

bw.Write(Math.Cos(a));

end;

// flush any pending output

bw.Flush;

// save the compressed data

m_CompressedData := ms.GetBuffer;

// done

  msg := System.String.Format('Generated table with {0}
points, saved into {1} bytes', System.Object(count),
System.Object(Length(m_CompressedData)));

label1.Text := msg;

// we can now expand it

button3.Enabled := true;

end;


C1Zip Compressing Binary Data - Visual Basic

Visual Basic

' compress/expand binary data

Private m_CompressedData As Byte()

Private Sub btnCompressData_Click(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles btnCompressData.Click

' open memory stream

Dim ms As MemoryStream = New MemoryStream()

' attach compressor stream to memory stream

Dim sw As C1ZStreamWriter = New C1ZStreamWriter(ms)

' attach BinaryWriter to the compressor stream

Dim bw As BinaryWriter = New BinaryWriter(sw)

' write a bunch of numbers into the stream

Dim i As Integer

Dim count As Integer = 1000

bw.Write(count)

For i = 0 To count - 1

Dim a As Double = i * Math.PI / 180.0

bw.Write(i)

bw.Write(a)

bw.Write(Math.Sin(a))

bw.Write(Math.Cos(a))

Next

' flush any pending output

bw.Flush()

' save the compressed data

m_CompressedData = ms.ToArray()

' done

Dim msg As String

msg =String.Format("Generated table with {0} points," & _

" saved into {1} bytes", count, m_CompressedData.Length)

label1.Text = msg

' we can now expand it

btnExpandData.Enabled = True

End Sub


C1Zip CompressStrings - C#

C#

(private byte[] m_CompressedString;

private void btnCompressString_Click(System.object sender,

System.EventArgs e)

{

// compress the string

long ticks = DateTime.Now.Ticks;

m_CompressedString = CompressString(textBox1.Text);

// tell user how long it took

int ms = (DateTime.Now.Ticks - ticks) / TimeSpan.TicksPerMillisecond;

int lenBefore = textBox1.Text.Length * 2;

int lenAfter = m_CompressedString.Length;

string msg = string .Format("Compressed from {0} bytes to " +

"{1} bytes in {2} milliseconds.", lenBefore, lenAfter, ms);

MessageBox.Show(msg, "Compressed",

MessageBoxButtons.OK, MessageBoxIcon.Information);

// we can now expand it

btnExpandString.Enabled = true;

}


C1Zip CompressStrings - Delphi

Delphi

m_CompressedString: array of byte;

procedure btnCompressString_Click(sender: System.Object;

e: System.EventArgs);

var

ticks: Long;

ms: Integer;

lenBefore: Integer;

lenAfter: Integer;

msg: string;

begin

// compress the string

ticks := DateTime.Now.Ticks;

m_CompressedString := CompressString(textBox1.Text);

// tell user how long it took

ms := (DateTime.Now.Ticks - ticks) / TimeSpan.TicksPerMillisecond;

lenBefore := textBox1.Text.Length * 2;

lenAfter := m_CompressedString.Length;

msg := System.String.Format('Compressed from {0} bytes to {1} bytes in {2} milliseconds.', lenBefore, lenAfter, ms);

MessageBox.Show(msg, 'Compressed', MessageBoxButtons.OK, MessageBoxIcon.Information);

// we can now expand it

btnExpandString.Enabled := True

end;


C1Zip CompressStringsFunction - C#

C#

public byte() CompressString(string str) {

// open memory stream

MemoryStream MemoryStream ms = new MemoryStream();

// attach compressor stream to memory stream

C1ZStreamWriter C1ZStreamWriter sw = new C1ZStreamWriter(ms);

// write data into compressor stream

StreamWriter StreamWriter writer = new StreamWriter(sw);

writer.Write(str);

// flush any pending data

writer.Flush();

// return the memory buffer

CompressString = ms.ToArray();

}


C1Zip CompressStringsFunction - Delphi

Delphi

function TWinForm.CompressString(const S: string): TByteArray;

var

ms: MemoryStream;

sw: C1ZStreamWriter;

writer: StreamWriter;

begin

// open memory stream

ms := MemoryStream.Create;

// attach compressor stream to memory stream

sw := C1ZStreamWriter.Create(ms);

// write data into compressor stream

writer := StreamWriter.Create(sw);

writer.Write(S);

// flush any pending data

writer.Flush;

// return the memory buffer

// (note: don't use GetBuffer(), it may return an array that is too long)

Result := ms.ToArray;

end;


C1Zip CompressStringsFunction - Visual Basic

Visual Basic

Public Function CompressString(ByVal str As String) As Byte()

' open memory stream

Dim ms As MemoryStream = New MemoryStream()

' attach compressor stream to memory stream

Dim sw As C1ZStreamWriter = New C1ZStreamWriter(ms)

' write data into compressor stream

Dim writer As StreamWriter = New StreamWriter(sw)

writer.Write(str)

' flush any pending data

writer.Flush()

' return the memory buffer

CompressString = ms.ToArray()

End Function


C1Zip CompressStrings - Visual Basic

Visual Basic

Dim m_CompressedString As Byte()

Private Sub btnCompressString_Click(ByVal sender As System.Object,

ByVal e As System.EventArgs) Handles btnCompressString.Click

' compress the string

Dim ticks As Long = DateTime.Now.Ticks

m_CompressedString = CompressString(textBox1.Text)

' tell user how long it took

Dim ms As Integer

ms = (DateTime.Now.Ticks - ticks) / TimeSpan.TicksPerMillisecond

Dim lenBefore As Integer = textBox1.Text.Length * 2

Dim lenAfter As Integer = m_CompressedString.Length

Dim msg As String

msg = String.Format("Compressed from {0} bytes to " &

"{1} bytes in {2} milliseconds.", lenBefore, lenAfter, ms)

MessageBox.Show(msg, "Compressed", _

MessageBoxButtons.OK, MessageBoxIcon.Information)

' we can now expand it

btnExpandString.Enabled = True

End Sub


C1Zip Create Data Table - C#

C#

private void btnCreate_Click(object sender,EventArgs e) btnCreate.Click {

// open table

string conn =

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + MDBFILE + ";";

string rs = "select * from customers";

// show status

Cursor = Cursors.WaitCursor;

statusBar1.Text = "Loading data from mdb file...";

// load data

OleDbDataAdapter OleDbDataAdapter da = new OleDbDataAdapter(rs, conn);

DataSet DataSet ds = new DataSet();

try

{

da.Fill(ds);

}

catch

{

MessageBox.Show("Could not load data from " + MDBFILE);

}

// show status

Cursor = Cursors.Default;

statusBar1.Text = "Loaded " + ds.Tables[0].Rows.Count +

" records from mdb file.";

// bind to grid

dataGrid1.DataSource = ds.Tables[0];

// enable save button

btnSave.Enabled = true;

}


C1Zip Create Data Table - Delphi

Delphi

procedure TWinForm.btnCreate_Click(sender: System.Object; e: System.EventArgs);

var

da: OleDbDataAdapter;

ds: DataSet;

begin

// show status

Cursor := Cursors.WaitCursor;

statusBar1.Text := 'Loading data from mdb file...';

// open table

// load data

da := OleDbDataAdapter.Create('select * from customers',

'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + MDBFILE + ';');

ds := DataSet.Create;

da.Fill(ds, 'customers');

// show status

Cursor := Cursors.Default;

statusBar1.Text := 'Loaded ' + ds.Tables[0].Rows.Count.ToString + ' records from mdb file.';

// bind to grid

dataGrid1.DataSource := ds.Tables[0];

// enable save button

btnSave.Enabled := true;

end;


C1Zip Create Data Table - Visual Basic

Visual Basic

Private Sub btnCreate_Click(sender As Object, _

e As EventArgs) Handles btnCreate.Click

' open table

Dim conn As String

conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MDBFILE & ";"

Dim rs As String = "select * from customers"

' show status

Cursor = Cursors.WaitCursor

statusBar1.Text = "Loading data from mdb file..."

' load data

Dim da As OleDbDataAdapter = New OleDbDataAdapter(rs, conn)

Dim ds As DataSet = New DataSet()

Try

da.Fill(ds)

Catch

MessageBox.Show("Could not load data from " + MDBFILE)

End Try

' show status

Cursor = Cursors.Default

statusBar1.Text = "Loaded " & _

ds.Tables(0).Rows.Count & _

" records from mdb file."

' bind to grid

dataGrid1.DataSource = ds.Tables(0)

' enable save button

btnSave.Enabled = True

End Sub


C1Zip Declare Constants - C#

C#

private const string FN_REGULAR = @"\DataTable.regular";

private const string FN_COMPRESSED = @"\DataTable.compressed";

private const string MDBFILE =

@"C:\Program Files\ComponentOne Studio.NET\common\NWIND.MDB";


C1Zip Declare Constants - Delphi

Delphi

const

MDBFILE = 'D:\Program Files\ComponentOne Studio.NET\common\NWIND.MDB';

FN_REGULAR = '\DataTable.regular';

FN_COMPRESSED = '\DataTable.compressed';


C1Zip Declare Constants - Visual Basic

Visual Basic

Private Const FN_REGULAR = "\DataTable.regular"

Private Const FN_COMPRESSED = "\DataTable.compressed"

Private Const MDBFILE = "C:\Program Files\ComponentOne Studio.NET\common\NWIND.MDB"


C1Zip DeCompressString - C#

C#

private void btnExpandString_Click(System.object sender, System.EventArgs e)

{

// expand the string

long ticks = DateTime.Now.Ticks;

textBox1.Text = ExpandString(m_CompressedString);

// tell user how long it took

int ms = (DateTime.Now.Ticks - ticks) / TimeSpan.TicksPerMillisecond;

int lenBefore = m_CompressedString.Length;

int lenAfter = textBox1.Text.Length * 2;

string msg;

msg = string .Format("Expanded from {0} bytes to {1} bytes " +

"in {2} milliseconds.", lenBefore, lenAfter, ms);

MessageBox.Show(msg, "Expanded", MessageBoxButtons.OK, MessageBoxIcon.Information);

}


C1Zip DeCompressString - Delphi

Delphi

procedure TWinForm.button2_Click(sender: System.Object; e: System.EventArgs);

var

ticks: Int64;

ms, lenBefore, lenAfter: Integer;

msg: string;

begin

// expand the string

ticks := DateTime.Now.Ticks;

textBox1.Text := ExpandString(m_CompressedString);

// tell user how long it took

ms := Round((DateTime.Now.Ticks - ticks) / TimeSpan.TicksPerMillisecond);

lenBefore := Length(m_CompressedString);

lenAfter := textBox1.Text.Length * 2; // << 1 unicode char = 2 bytes

  msg := System.String.Format('Expanded from {0} bytes to
{1} bytes in {2} milliseconds.', System.Object(lenBefore),
System.Object(lenAfter), System.Object(ms));

MessageBox.Show(msg, 'Expanded', MessageBoxButtons.OK, MessageBoxIcon.Information);

end;


C1Zip DeCompressString - Visual Basic

Visual Basic

Private Sub btnExpandString_Click(ByVal sender As System.Object,

ByVal e As System.EventArgs) Handles btnExpandString.Click

' expand the string

Dim ticks As Long = DateTime.Now.Ticks

textBox1.Text = ExpandString(m_CompressedString)

' tell user how long it took

Dim ms As Integer

ms = (DateTime.Now.Ticks - ticks) / TimeSpan.TicksPerMillisecond

Dim lenBefore As Integer = m_CompressedString.Length

Dim lenAfter As Integer = textBox1.Text.Length * 2

Dim msg As String

msg = String.Format("Expanded from {0} bytes to {1} bytes " & _

"in {2} milliseconds.", lenBefore, lenAfter, ms)

MessageBox.Show(msg, "Expanded", MessageBoxButtons.OK, MessageBoxIcon.Information)

End Sub


C1Zip Define Directory Names - C#

C#

private const DIR_COMP = "\compressed"

private const DIR_EXP = "\expanded"


C1Zip Define Directory Names - Delphi

Delphi

private const DIR_COMP := '\compressed';

private const DIR_EXP := '\expanded';


C1Zip Define Directory Names - Visual Basic

Visual Basic

Private Const DIR_COMP = "\compressed"

Private Const DIR_EXP = "\expanded"


C1Zip ExpandFile Function - C#

C#

private bool ExpandFile(string dstFile, string srcFile) {

// prepare to expand file

bool retval = true;

FileStream srcStream = null;

FileStream dstStream = null;

try

{

// open the files

srcStream = new FileStream(srcFile, FileMode.Open, FileAccess.Read);

dstStream = new FileStream(dstFile, FileMode.Create, FileAccess.Write);

// open expander stream on compressed source

C1ZStreamReader C1ZstreamReader sr = new C1ZStreamReader(srcStream);

// copy expander stream into destination file|

StreamCopy(dstStream, sr);

}

catch // exception? tell caller we failed

{

retval = false;

}

finally// always close our streams

{

if (srcStream != null) srcStream.Close();

if (dstStream != null) dstStream.Close();

}

// done

return retval;

}


C1Zip ExpandFile Function - Delphi

Delphi

function TWinForm.ExpandFile(const ADstFile: string; const ASrcFile: string): Boolean;

var

ASrcStream, ADstStream: FileStream;

AReader: C1ZStreamReader;

begin

ASrcStream := nil;

ADstStream := nil;

try

try

// open the files

ASrcStream := FileStream.Create(ASrcFile, FileMode.Open, FileAccess.Read);

ADstStream := FileStream.Create(ADstFile, FileMode.Create, FileAccess.Write);

// open expander stream on compressed source

AReader := C1ZStreamReader.Create(ASrcStream);

// copy expander stream into destination file

StreamCopy(ADstStream, AReader);

Result := True;

except

Result := False;

end;

finally

if ASrcStream <> nil then

ASrcStream.Close;

if ADstStream <> nil then

ADstStream.Close;

end;


C1Zip ExpandFile Function - Visual Basic

Visual Basic

Private Function ExpandFile(dstFile As String, srcFile As String) As Boolean

' prepare to expand file

Dim retval As Boolean = True

Dim srcStream As FileStream

Dim dstStream As FileStream

Try

' open the files

srcStream = New FileStream(srcFile, FileMode.Open, FileAccess.Read)

dstStream = New FileStream(dstFile, FileMode.Create, FileAccess.Write)

' open expander stream on compressed source

Dim sr As C1ZstreamReader = New C1ZStreamReader(srcStream)

' copy expander stream into destination file

StreamCopy(dstStream, sr)

Catch ' exception? tell caller we failed

retval = False

Finally ' always close our streams

If Not (srcStream Is Nothing) Then srcStream.Close()

If Not (dstStream Is Nothing) Then dstStream.Close()

End Try

' done

ExpandFile = retval

End Sub


C1Zip ExpandFiles - C#

C#

private void btnExpand_Click(object sender, EventArgs e) btnExpand.Click {

// get application directory

string appPath = Application.ExecutablePath;

int i = appPath.IndexOf(@"\bin\");

if (i > 0) appPath = appPath.Substring(0, i);

// create directory for expanded files

if (Directory.Exists(appPath + DIR_EXP))

Directory.Delete(appPath + DIR_EXP, true);

Directory.CreateDirectory(appPath + DIR_EXP);

// prepare to collect compression statistics

long count = 0;

long size = 0;

long sizeExpanded = 0;

long ticks = DateTime.Now.Ticks;

// expand all files in "compressed" dir to "expanded" dir

( string[] files = Directory.GetFiles(appPath + DIR_COMP);

foreach (string srcFile in files)

{

// expand file

string dstFile = appPath + DIR_EXP + @"\" +

Path.GetFileName(srcFile);

dstFile = dstFile.Replace(".cmp", "");

ExpandFile(dstFile, srcFile);

// update stats

count++;

size += new FileInfo(srcFile).Length;

sizeExpanded += new FileInfo(dstFile).Length;

}

// show stats

string msg = string .Format(

"Expanded {0} files in {1} ms.\r\n" +

"Original size: {2:#,###}\r\n" +

"Expanded size: {3:#,###} ({4:0.00} x size of compressed)",

count,

(DateTime.Now.Ticks - ticks) / TimeSpan.TicksPerMillisecond,

size,

sizeExpanded,

sizeExpanded / size);

label1.Text = msg;

}


C1Zip ExpandFiles - Delphi

Delphi

procedure TWinForm.btnExpand_Click(Sender: System.Object; e: System.EventArgs);

var

msg, path, dstFile: string;

files: array of string;

I: Integer;

fparams: array of TObject;

count, size, sizeExpanded, ticks: Integer;

begin

// get application directory

path := System.IO.Path.GetDirectoryName(Application.ExecutablePath);

// create directory for compressed files

if Directory.Exists(path + DIR_EXP) then

Directory.Delete(path + DIR_EXP, True);

Directory.CreateDirectory(path + DIR_EXP);

// prepare to collect compression statistics

count := 0;

size := 0;

sizeExpanded := 0;

ticks := DateTime.Now.Ticks;

files := Directory.GetFiles(path + DIR_COMP);

for I := 0 to High(files) do

begin

// compress file

dstFile := path + DIR_EXP + '\' + System.IO.Path.GetFileName(files[I]);

ExpandFile(dstFile, files[I]);

// update stats

Inc(count);

size := size + FileInfo.Create(files[I]).Length;

sizeExpanded := sizeExpanded + FileInfo.Create(dstFile).Length;

end;

// show stats

SetLength(fparams, 5);

fparams[0] := System.Object(count);

fparams[1] := System.Object((DateTime.Now.Ticks - ticks) / TimeSpan.TicksPerMillisecond);

fparams[2] := System.Object(size);

fparams[3] := System.Object(sizeExpanded);

fparams[4] := System.Object(((sizeExpanded) / (size)) * 100.0);

msg := System.String.Format(

'Expanded {0} files in {1} ms.'#13#10 +

'Original size: {2:#,###}'#13#10 +

'Expanded size: {3:#,###} ({4:0.00}% of original)', fparams);

label1.Text := msg;

end;


C1Zip ExpandFiles - Visual Basic

Visual Basic

Private Sub btnExpand_Click(sender As Object, e As EventArgs) Handles btnExpand.Click

' get application directory

Dim appPath As String = Application.ExecutablePath

Dim i As Integer = appPath.IndexOf("\bin\")

If i > 0 Then appPath = appPath.Substring(0, i)

' create directory for expanded files

If Directory.Exists(appPath + DIR_EXP) Then

Directory.Delete(appPath + DIR_EXP, True)

End If

Directory.CreateDirectory(appPath + DIR_EXP)

' prepare to collect compression statistics

Dim count As Long

Dim size As Long

Dim sizeExpanded As Long

Dim ticks As Long = DateTime.Now.Ticks

' expand all files in "compressed" dir to "expanded" dir

Dim srcFile As String

Dim files As String()

files = Directory.GetFiles(appPath + DIR_COMP)

For Each srcFile In files

' expand file

Dim dstFile As String = _

appPath + DIR_EXP + "\" + Path.GetFileName(srcFile)

dstFile = dstFile.Replace(".cmp", "")

ExpandFile(dstFile, srcFile)

' update stats

count = count + 1

size = size + New FileInfo(srcFile).Length

sizeExpanded = sizeExpanded + New FileInfo(dstFile).Length

Next

' show stats

Dim msg As String

msg = String.Format(_

"Expanded {0} files in {1} ms." & vbCrLf & _

"Original size: {2:#,###}" & vbCrLf & _

"Expanded size: {3:#,###} ({4:0.00} x size of compressed)", _

count, _

(DateTime.Now.Ticks - ticks) / TimeSpan.TicksPerMillisecond, _

size, _

sizeExpanded, _

sizeExpanded / size)

label1.Text = msg

End Sub


C1Zip Expanding Binary Data - C#

C#

private void btnExpandData_Click(System.object sender, System.EventArgs e)

{

// open memory stream on saved data

MemoryStream MemoryStream ms = new MemoryStream(m_CompressedData);

// attach decompressor stream to memory stream

C1ZStreamReader C1ZStreamReader sr = new C1ZStreamReader(ms);

// read uncompressed data

int i;

BinaryReader BinaryReader br = new BinaryReader(sr);

int count = br.ReadInt32();

for (i = 0 ; GAIS <= count – 1

int deg = br.ReadInt32();

double rad = br.ReadDouble();

double sin = br.ReadDouble();

double cos = br.ReadDouble();

}

// done

string msg;

msg = string .Format("Read table with {0} points " +

"from stream with {1} bytes.", count, m_CompressedData.Length);

label1.Text = msg;

}


C1Zip Expanding Binary Data - Delphi

Delphi

procedure TWinForm.button3_Click(sender: System.Object; e: System.EventArgs);

var

ms: MemoryStream;

sr: C1ZStreamReader;

br: BinaryReader;

I, count: Integer;

msg: string;

deg: Integer;

rad, sin, cos: double;

begin

// open memory stream on saved data

ms := MemoryStream.Create(m_CompressedData);

// attach decompressor stream to memory stream

sr := C1ZStreamReader.Create(ms);

// read uncompressed data

br := BinaryReader.Create(sr);

count := br.ReadInt32;

for I := 0 to count - 1 do

begin

deg := br.ReadInt32;

rad := br.ReadDouble;

sin := br.ReadDouble;

cos := br.ReadDouble;

end;

// done, tell user about it

  msg := System.String.Format('Read table with {0} points
from stream with {1} bytes.', System.Object(count),
System.Object(Length(m_CompressedData)));

label1.Text := msg;

end;


C1Zip Expanding Binary Data - Visual Basic

Visual Basic

Private Sub btnExpandData_Click(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles btnExpandData.Click

' open memory stream on saved data

Dim ms As MemoryStream = New MemoryStream(m_CompressedData)

' attach decompressor stream to memory stream

Dim sr As C1ZStreamReader = New C1ZStreamReader(ms)

' read uncompressed data

Dim i As Integer

Dim br As BinaryReader = New BinaryReader(sr)

Dim count As Integer = br.ReadInt32()

For i = 0 To count - 1

Dim deg As Integer = br.ReadInt32()

Dim rad As Double = br.ReadDouble()

Dim sin As Double = br.ReadDouble()

Dim cos As Double = br.ReadDouble()

Next

' done

Dim msg As String

msg = String.Format("Read table with {0} points " & _

"from stream with {1} bytes.", count, m_CompressedData.Length)

label1.Text = msg

End Sub


C1Zip ExpandString - C#

C#

public string ExpandString(byte(buffer))

{

// turn buffer into a memory stream

MemoryStream MemoryStream ms = new MemoryStream(buffer);

// attach decompressor stream to memory stream

C1ZStreamReader C1ZStreamReader sr = new C1ZStreamReader(ms);

// read uncompressed data

StreamReader StreamReader reader = new StreamReader(sr);

ExpandString = reader.ReadToEnd();

}


C1Zip ExpandString - Delphi

Delphi

function TWinForm.ExpandString(buffer: TByteArray): string;

var

ms: MemoryStream;

sr: C1ZStreamReader;

reader: StreamReader;

begin

// turn buffer into a memory stream

ms := MemoryStream.Create(buffer);

// attach decompressor stream to memory stream

sr := C1ZStreamReader.Create(ms);

// read uncompressed data

reader := StreamReader.Create(sr);

Result := reader.ReadToEnd;

end;


C1Zip ExpandString - Visual Basic

Visual Basic

Public Function ExpandString(ByVal buffer As Byte()) As String

' turn buffer into a memory stream

Dim ms As MemoryStream = New MemoryStream(buffer)

' attach decompressor stream to memory stream

Dim sr As C1ZStreamReader = New C1ZStreamReader(ms)

' read uncompressed data

Dim reader As StreamReader = New StreamReader(sr)

ExpandString = reader.ReadToEnd()

End Function


C1Zip Extract Files - C#

C#

private void btnExtract_Click(object sender, EventArgs e) {

// make sure we have some selected entries

int cnt = ListView1.SelectedIndices.Count;

if (cnt == 0 )

{

MessageBox.Show("Sorry, no files to extract...", "C1Zip");

return;

}

// confirm with user

DialogResult dr;

string msg;

msg = "Please confirm that you want to extract " +

cnt.ToString() + " entries.";

dr = MessageBox.Show(msg, "C1Zip",

MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

if (dr != DialogResult.OK) return;

// extract all selected entries

foreach (ListViewItem lvi In ListView1.SelectedItems)

{

C1ZipEntry ze = lvi.Tag;

if (ze.SizeCompressed > 0) {

m_Zip.Entries.Extract(ze.FileName);

}

}

// done

UpdateDisplay();

}


C1Zip Extract Files - Delphi

Delphi

procedure btnExtract_Click(sender: System.Object; e: System.EventArgs);

var

cnt: Integer;

dr: System.Windows.Forms.DialogResult;

msg: string;

lvi: ListViewItem;

ze: C1ZipEntry;

i: Integer;

begin

// make sure we have some selected entries

cnt := ListView1.SelectedIndices.Count;

if cnt = 0 then

begin

MessageBox.Show('Sorry, no files to extract...','C1Zip');

exit;

end;

// confirm with user

msg := 'Please confirm that you want to extract ' + cnt.ToString + ' entries.';

dr := MessageBox.Show(msg, 'C1Zip', MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

if dr <> System.Windows.Forms.DialogResult.OK then Exit

// extract all selected entries

for i := 0 to listView1.SelectedItems.Count - 1 do

begin

lvi := listView1.SelectedItems[i];

ze := lvi.Tag;

if ze.SizeCompressed > 0 then

m_Zip.Entries.Extract(ze.FileName);

end;

// done

UpdateDisplay;

end;


C1Zip Extract Files - Visual Basic

Visual Basic

Private Sub btnExtract_Click(sender As Object, e As EventArgs) Handles btnExtract.Click

' make sure we have some selected entries

Dim cnt As Integer = ListView1.SelectedIndices.Count

If cnt = 0 Then

MessageBox.Show("Sorry, no files to extract...", "C1Zip")

Exit Sub

End If

' confirm with user

Dim dr As DialogResult

Dim msg As String

msg = "Please confirm that you want to extract " &

cnt.ToString() + " entries."

dr = MessageBox.Show(msg, "C1Zip", _

MessageBoxButtons.OKCancel, MessageBoxIcon.Question)

If dr <> DialogResult.OK Then Exit Sub

' extract all selected entries

Dim lvi As ListViewItem

Dim ze As C1ZipEntry

For Each lvi In ListView1.SelectedItems

ze = lvi.Tag

If ze.SizeCompressed > 0 Then

m_Zip.Entries.Extract(ze.FileName)

End If

Next

' done

UpdateDisplay()

End Sub


C1Zip FAQ - C#

C#

private void button1_Click(object sender, System.EventArgs e)

{

C1ZipFile zip = new C1ZipFile();

zip.Create(@"c:\temp\test.zip");

Stream s = zip.Entries.OpenWriter("entry1", true);

StreamWriter sw = new StreamWriter(s);

sw.WriteLine("Hello world");

// continue writing as much as you want...

sw.Close();

s = zip.Entries.OpenWriter("entry2", true);

sw = new StreamWriter(s);

sw.WriteLine("Hello again");

// continue writing as much as you want...

sw.Close();

}


C1Zip FAQ - Delphi

Delphi

procedure Class1.button1_Click(sender: System.Object; e: System.EventArgs);

var

sw: StreamWriter;

s: Stream;

zip: C1ZipFile;

begin

zip := C1ZipFile.Create;

zip.Create('c:\temp\test.zip');

s := zip.Entries.OpenWriter('entry1', True);

sw := StreamWriter.Create(s);

sw.WriteLine('Hello world');

sw.Close;

s := zip.Entries.OpenWriter('entry2', True);

sw := StreamWriter.Create(s);

sw.WriteLine('Hello again');

sw.Close;

end;


C1Zip FAQ - Visual Basic

Visual Basic

Private Sub button1_Click(sender As Object, e As System.EventArgs)

Dim zip As New C1ZipFile()

zip.Create("")

Dim s As Stream = zip.Entries.OpenWriter("entry1", True)

Dim sw As New StreamWriter(s)

sw.WriteLine("Hello world")

' continue writing as much as you want...

sw.Close()

s = zip.Entries.OpenWriter("entry2", True)

sw = New StreamWriter(s)

sw.WriteLine("Hello again")

' continue writing as much as you want...

sw.Close()

End Sub


C1ZipFile EntriesCollection - C#

C#

myZip.Entries.Add("MyData.txt");

myZip.Entries.Add("MyData.xml");

myZip.Entries.Add("MyData.doc");

foreach (C1ZipEntry zipEntry in myZip.Entries)

Console.WriteLine(zipEntry.Name);


C1ZipFile EntriesCollection - Delphi

Delphi

var

i: Integer;

begin

myZip.Entries.Add('MyData.txt');

myZip.Entries.Add('MyData.xml');

myZip.Entries.Add('MyData.doc');

for I := 0 to myZip.Entries.Count – 1 do

Console.Writeln(myZip.Entries[I].Name);

end;


C1ZipFile EntriesCollection - Visual Basic

Visual Basic

myZip.Entries.Add("MyData.txt")

myZip.Entries.Add("MyData.xml")

myZip.Entries.Add("MyData.doc")

Dim zipEntry As C1ZipEntry

For Each zipEntry In myZip.Entries

Console.WriteLine(zipEntry.Name)

Next zipEntry


C1ZipFile Object - C#

C#

// create a C1ZipFile object:

C1ZipFile myZip = new C1ZipFile();

// create a new (empty) zip file

myZip.Create("New.zip");

// open an existing zip file

myZip.Open("Old.zip");


C1ZipFile Object - Delphi

Delphi

var

myZip: C1ZipFile;

begin

// create a C1ZipFile object:

myZip := C1ZipFile.Create;

// create a new (empty) zip file;

myZip.Create('New.zip');

// open an existing zip file;

myZip.Open('Old.zip');

end;


C1ZipFile Object - Visual Basic

Visual Basic

' create a C1ZipFile object:

Dim myZip As New C1ZipFile()

' create a new (empty) zip file

myZip.Create("New.zip")

' open an existing zip file

myZip.Open("Old.zip")


C1ZipImports - C#

C#

using C1File = C1.C1Zip.C1ZipFile;

using MyFile = MyProject.C1ZipFile;

C1File f1;

MyFile f2;


C1ZipImports - Delphi

Delphi

uses

C1File, MyFile;

var

f2: MyFile;

f1: C1File;

begin

C1File := C1.C1Zip.C1ZipFile;

MyFile := MyProject.C1ZipFile;

end;


C1ZipImports - Visual Basic

Visual Basic

Imports C1File = C1.C1Zip.C1ZipFile

Imports MyFile = MyProject.C1ZipFile

Dim f1 As C1File

Dim f2 As MyFile


C1Zip Load Compressed Data Table - C#

C#

private void btnLoadCompressed_Click(object sender, EventArgs e)

{

// clear grid, show status

Cursor = Cursors.WaitCursor;

dataGrid1.DataSource = null;

statusBar1.Text = "Loading from compressed file...";

// deserialize from compressed file

string fn = Application.StartupPath + FN_COMPRESSED;

FileStream fs = new FileStream(fn, FileMode.Open);

long ticks = DateTime.Now.Ticks;

C1ZstreamReader decompressor;

decompressor = new C1ZStreamReader(fs);

BinaryFormatter BinaryFormatter bf = new BinaryFormatter();

DataTable dt = bf.Deserialize(decompressor);

long ms =

(DateTime.Now.Ticks - ticks) / TimeSpan.TicksPerMillisecond;

fs.Close();

// show result

Cursor = Cursors.Default;

dataGrid1.DataSource = dt;

statusBar1.Text =

"Loaded from compressed file in " + ms.ToString() + " ms.";

}


C1Zip Load Compressed Data Table - Delphi

Delphi

procedure TWinForm.btnLoadCompressed_Click(sender: System.Object; e: System.EventArgs);

var

fn: string;

fs: FileStream;

decompressor: C1ZStreamReader;

bf: BinaryFormatter;

ticks: Int64;

dt: DataTable;

ms: Int64;

begin

// clear grid, show status

Cursor := Cursors.WaitCursor;

dataGrid1.DataSource := nil;

statusBar1.Text := 'Loading DataTable from compressed file...';

// deserialize from regular file

fn := Application.StartupPath + FN_COMPRESSED;

fs := FileStream.Create(fn, FileMode.Open);

decompressor := C1ZStreamReader.Create(fs);

bf := BinaryFormatter.Create;

ticks := DateTime.Now.Ticks;

dt := DataTable(bf.Deserialize(decompressor));

ms := Round((DateTime.Now.Ticks - ticks)/TimeSpan.TicksPerMillisecond);

fs.Close;

// show result

Cursor := Cursors.Default;

dataGrid1.DataSource := dt;

statusBar1.Text := 'Loaded data from compressed file in ' + ms.ToString + ' ms.';

end;


C1Zip Load Compressed Data Table - Visual Basic

Visual Basic

Private Sub btnLoadCompressed_Click(sender As Object, e As EventArgs) Handles btnLoadCompressed.Click

' clear grid, show status

Cursor = Cursors.WaitCursor

dataGrid1.DataSource = Nothing

statusBar1.Text = "Loading from compressed file..."

' deserialize from compressed file

Dim fn As String = Application.StartupPath + FN_COMPRESSED

Dim fs As FileStream = New FileStream(fn, FileMode.Open)

Dim ticks As Long = DateTime.Now.Ticks

Dim decompressor As C1ZstreamReader

decompressor = New C1ZStreamReader(fs)

Dim bf As BinaryFormatter = New BinaryFormatter()

Dim dt As DataTable = bf.Deserialize(decompressor)

Dim ms As Long = _

(DateTime.Now.Ticks - ticks) / TimeSpan.TicksPerMillisecond

fs.Close()

' show result

Cursor = Cursors.Default

dataGrid1.DataSource = dt

statusBar1.Text = "Loaded from compressed file in " & ms.ToString() & " ms."

End Sub


C1Zip Load Data Table - C#

C#

private void btnLoad_Click(object sender, EventArgs e) btnLoad.Click {

// clear grid, show status

Cursor = Cursors.WaitCursor;

dataGrid1.DataSource = null;

statusBar1.Text = "Loading from regular file...";

// deserialize from regular file

string fn = Application.StartupPath + FN_REGULAR;

FileStream fs = new FileStream(fn, FileMode.Open);

long ticks = DateTime.Now.Ticks;

BinaryFormatter BinaryFormatter bf = new BinaryFormatter();

DataTable dt = bf.Deserialize(fs);

long ms =

(DateTime.Now.Ticks - ticks) / TimeSpan.TicksPerMillisecond;

fs.Close();

// show result

Cursor = Cursors.Default;

dataGrid1.DataSource = dt;

statusBar1.Text =

"Loaded from regular file in " + ms.ToString() + " ms.";

}


C1Zip Load Data Table - Delphi

Delphi

procedure TWinForm.btnLoad_Click(sender: System.Object; e: System.EventArgs);

var

fn: string;

fs: FileStream;

bf: BinaryFormatter;

ticks: Int64;

dt: DataTable;

ms: Int64;

begin

// clear grid, show status

Cursor := Cursors.WaitCursor;

dataGrid1.DataSource := nil;

statusBar1.Text := 'Loading DataTable from regular file...';

// deserialize from regular file

fn := Application.StartupPath + FN_REGULAR;

fs := FileStream.Create(fn, FileMode.Open);

bf := BinaryFormatter.Create;

ticks := DateTime.Now.Ticks;

dt := DataTable(bf.Deserialize(fs));

ms := Round((DateTime.Now.Ticks - ticks) / TimeSpan.TicksPerMillisecond);

fs.Close;

// show result

Cursor := Cursors.Default;

dataGrid1.DataSource := dt;

statusBar1.Text := 'Loaded data from regular file in '+ ms.ToString + ' ms.';

end;


C1Zip Load Data Table - Visual Basic

Visual Basic

Private Sub btnLoad_Click(sender As Object, e As EventArgs) Handles btnLoad.Click

' clear grid, show status

Cursor = Cursors.WaitCursor

dataGrid1.DataSource = Nothing

statusBar1.Text = "Loading from regular file..."

' deserialize from regular file

Dim fn As String = Application.StartupPath & FN_REGULAR

Dim fs As FileStream = New FileStream(fn, FileMode.Open)

Dim ticks As Long = DateTime.Now.Ticks

Dim bf As BinaryFormatter = New BinaryFormatter()

Dim dt As DataTable = bf.Deserialize(fs)

Dim ms As Long = _

(DateTime.Now.Ticks - ticks) / TimeSpan.TicksPerMillisecond

fs.Close()

' show result

Cursor = Cursors.Default

dataGrid1.DataSource = dt

statusBar1.Text = _

"Loaded from regular file in " & ms.ToString() & " ms."

End Sub


C1Zip Passwords - C#

C#

using C1.C1Zip;

C1ZipFile C1ZipFile zip = new C1ZipFile();

zip.CompressionLevel = CompressionLevelEnum.BestCompression;

zip.Create(@"c:\temp\test.zip");

zip.Entries.Add(@"c:\file1.bmp");

zip.Password = "first";

zip.Entries.Add(@"c:\file2.bmp");

zip.Password = "second";

zip.Entries.Add(@"c:\file1.bmp");

zip.Password = "";


C1Zip Passwords - Delphi

Delphi

uses C1.C1Zip;

var

C1ZipFile: C1ZipFile;

begin

zip := C1ZipFile.Create;

zip.CompressionLevel := CompressionLevelEnum.BestCompression;

zip.Create('c:\temp\test.zip');

zip.Entries.Add('c:\file1.bmp');

zip.Password := 'first';

zip.Entries.Add('c:\file2.bmp');

zip.Password := 'second';

zip.Entries.Add('c:\file1.bmp');

zip.Password := '';

end;


C1Zip Passwords- Visual Basic

Visual Basic

Imports C1.C1Zip

Dim zip As C1ZipFile = New C1ZipFile()

zip.CompressionLevel = CompressionLevelEnum.BestCompression

zip.Create("c:\temp\test.zip")

zip.Entries.Add("c:\file1.bmp")

zip.Password = "first"

zip.Entries.Add("c:\file2.bmp")

zip.Password = "second"

zip.Entries.Add("c:\file1.bmp")

zip.Password = ""


C1Zip Remove Files - C#

C#

private void btnRemove_Click(object sender, EventArgs e) {

// make sure we have some selected entries

int cnt = ListView1.SelectedIndices.Count;

if (cnt = 0 ) {

MessageBox.Show("Oops, no files to remove...", "C1Zip");

return;

}

// confirm with user

DialogResult dr;

string msg;

msg = "Please confirm that you want to delete " +

cnt.ToString() + " entries.";

dr = MessageBox.Show(msg, "C1Zip",

MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

if (dr != DialogResult.OK) return;

// delete all selected entries

foreach (ListViewItem lvi In ListView1.SelectedItems)

{

C1ZipEntry ze = lvi.Tag as C1ZipEntry;

m_Zip.Entries.Remove(ze.FileName);

}

// done

UpdateDisplay();

}


C1Zip Remove Files - Delphi

Delphi

procedure btnRemove_Click(sender: System.Object; e: System.EventArgs);

var

cnt: Integer;

dr: DialogResult;

msg: string;

lvi: ListViewItem;

ze: C1ZipEntry;

i: Integer;

begin

// make sure we have some selected entries

cnt := ListView1.SelectedIndices.Count;

if cnt = 0 then

begin

MessageBox.Show('Oops, no files to remove...','C1Zip');

exit;

end;

// confirm with user

msg := 'Please confirm that you want to delete ' + cnt.ToString + ' entries.';

dr := MessageBox.Show(msg,'C1Zip', MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

if dr <> System.Windows.Forms.DialogResult.OK then

exit;

// delete all selected entries

for i := 0 to ListView1.SelectedItems.Count - 1 do

begin

lvi := ListView1.SelectedItems[i];

ze := lvi.Tag;

m_Zip.Entries.Remove(ze.FileName);

end;

// done

UpdateDisplay;

end;


C1Zip Remove Files - Visual Basic

Visual Basic

Private Sub btnRemove_Click(sender As Object, e As EventArgs) Handles btnRemove.Click

' make sure we have some selected entries

Dim cnt As Integer = ListView1.SelectedIndices.Count

If cnt = 0 Then

MessageBox.Show("Oops, no files to remove...", "C1Zip")

Exit Sub

End If

' confirm with user

Dim dr As DialogResult

Dim msg As String

msg = "Please confirm that you want to delete " + _

cnt.ToString() + " entries."

dr = MessageBox.Show(msg, "C1Zip", _

MessageBoxButtons.OKCancel, MessageBoxIcon.Question)

If dr <> DialogResult.OK Then Exit Sub

' delete all selected entries

Dim lvi As ListViewItem

Dim ze As C1ZipEntry

For Each lvi In ListView1.SelectedItems

ze = lvi.Tag

m_Zip.Entries.Remove(ze.FileName)

Next

' done

UpdateDisplay()

End Sub


C1Zip Save Data Table - C#

C#

private void btnSave_Click(object sender, EventArgs e) btnSave.Click {

// get data table from grid

DataTable dt = dataGrid1.DataSource;

// show status

Cursor = Cursors.WaitCursor;

statusBar1.Text = "Serializing data to regular file...";

// serialize the data set to a regular file

string fn = Application.StartupPath + FN_REGULAR;

FileStream fs = new FileStream(fn, FileMode.Create);

BinaryFormatter BinaryFormatter bf = new BinaryFormatter();

bf.Serialize(fs, dt);

long lenRegular = fs.Length;

fs.Close();

// show status

Cursor = Cursors.WaitCursor;

statusBar1.Text = "Serializing data to compressed file...";

// serialize the data set to a compressed file

fn = Application.StartupPath + FN_COMPRESSED;

fs = new FileStream(fn, FileMode.Create);

C1ZStreamWriter compressor = new C1ZStreamWriter(fs);

bf = new BinaryFormatter();

bf.Serialize(compressor, dt);

long lenCompressed = fs.Length;

fs.Close();

// show status

Cursor = Cursors.Default;

statusBar1.Text = string.Format(

"Saved to regular file ({0:#,###} bytes) and " +

"compressed file ({1:#,###} bytes)",

lenRegular, lenCompressed);

// enable load buttons

btnLoad.Enabled = true;

btnLoadCompressed.Enabled = true;

}


C1Zip Save Data Table - Delphi

Delphi

procedure TWinForm.btnSave_Click(sender: System.Object; e: System.EventArgs);

var

dt: DataTable;

fn: string;

fs: FileStream;

bf: BinaryFormatter;

lenRegular: Int64;

lenCompressed: Int64;

compressor: C1ZStreamWriter;

begin

// get data table from grid

dt := dataGrid1.DataSource as DataTable;

// show status

Cursor := Cursors.WaitCursor;

statusBar1.Text := 'Serializing data to regular file...';

// serialize the data set to a regular file

fn := Application.StartupPath + FN_REGULAR;

fs := FileStream.Create(fn, FileMode.Create);

bf := BinaryFormatter.Create;

bf.Serialize(fs, dt);

lenRegular := fs.Length;

fs.Close;

// show status

Cursor := Cursors.WaitCursor;

statusBar1.Text := 'Serializing data to compressed file...';

// serialize the data set to a compressed file

fn := Application.StartupPath + FN_COMPRESSED;

fs := FileStream.Create(fn, FileMode.Create);

compressor := C1ZStreamWriter.Create(fs);

bf := BinaryFormatter.Create;

bf.Serialize(compressor, dt);

lenCompressed := fs.Length;

fs.Close;

// show status

Cursor := Cursors.Default;

statusBar1.Text := System.String.Format(

'Saved to regular file (%d bytes) and ' +

'compressed file (%d bytes)',

System.Object(lenRegular), System.Object(lenCompressed));

// enable load buttons

btnLoad.Enabled := true;

btnLoadCompressed.Enabled := true;

end;


C1Zip Save Data Table - Visual Basic

Visual Basic

Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click

' get data table from grid

Dim dt As DataTable = dataGrid1.DataSource

' show status

Cursor = Cursors.WaitCursor

statusBar1.Text = "Serializing data to regular file..."

' serialize the data set to a regular file

Dim fn As String = Application.StartupPath + FN_REGULAR

Dim fs As FileStream = New FileStream(fn, FileMode.Create)

Dim bf As BinaryFormatter = New BinaryFormatter()

bf.Serialize(fs, dt)

Dim lenRegular As Long = fs.Length

fs.Close()

' show status

Cursor = Cursors.WaitCursor

statusBar1.Text = "Serializing data to compressed file..."

' serialize the data set to a compressed file

fn = Application.StartupPath & FN_COMPRESSED

fs = New FileStream(fn, FileMode.Create)

Dim compressor As C1ZStreamWriter = New C1ZStreamWriter(fs)

bf = New BinaryFormatter()

bf.Serialize(compressor, dt)

Dim lenCompressed As Long = fs.Length

fs.Close()

' show status

Cursor = Cursors.Default

statusBar1.Text = string.Format(_

"Saved to regular file ({0:#,###} bytes) and " & _

"compressed file ({1:#,###} bytes)",

lenRegular, lenCompressed)

' enable load buttons

btnLoad.Enabled = True

btnLoadCompressed.Enabled = True

End Sub


C1Zip SreamCopy Function - C#

C#

private void StreamCopy(Stream dstStream, Stream srcStream) {

byte[] buffer= new byte[32768];

for (;;)

{

int read = srcStream.Read(buffer, 0, buffer.Length);

if (read == 0) break;

dstStream.Write(buffer, 0, read);

}(

dstStream.Flush();

}


C1Zip SreamCopy Function - Delphi

Delphi

procedure TWinForm.StreamCopy(dstStream: Stream; srcStream: Stream);

var

buffer: array of byte;

read: Integer;

begin

SetLength(buffer, 32768);

repeat

read := srcStream.Read(buffer, 0, Length(buffer));

if read <> 0 then

dstStream.Write(buffer, 0, read);

until read = 0;

dstStream.Flush;

end;


C1Zip SreamCopy Function - Visual Basic

Visual Basic

Private Sub StreamCopy(dstStream As Stream, srcStream As Stream)

Dim buffer(32768) As Byte

Dim read As Integer

Do

read = srcStream.Read(buffer, 0, buffer.Length)

dstStream.Write(buffer, 0, read)

Loop While read > 0

dstStream.Flush()

End Sub


C1Zip streamReader - C#

C#

// save DataTable into compressed stream

BinaryFormatter bf = new BinaryFormatter();

FileStream fout = new FileStream("test.tmp", FileMode.Create);

bf.Serialize(fout, DataTableOut);

fout.Close();

// read compressed data

FileStream fin = new FileStream("test.tmp", FileMode.Open);

DataTable DataTableIn = bf.Deserialize(fin)


C1Zip streamReader - Delphi

Delphi

var

bf: BinaryFormatter;

fout: FileStream;

fin: FileStream;

DataTableIn: DataTable;

begin

bf := BinaryFormatter.Create;

fout := FileStream.Create('test.tmp', FileMode.Create);

fin := FileStream.Create('test.tmp', FileMode.Open);

// save DataTable into compressed stream

bf.Serialize(fout, DataTableOut);

fout.Close;

// read compressed data

DataTableIn := bf.Deserialize(fin);

end;


C1Zip streamReader - Visual Basic

Visual Basic

' save DataTable into compressed stream

Dim bf As New BinaryFormatter()

Dim fout As New FileStream("test.tmp", FileMode.Create)

bf.Serialize(fout, DataTableOut)

fout.Close()

' read compressed data

Dim fin As New FileStream("test.tmp", FileMode.Open)

Dim DataTableIn As DataTable = bf.Deserialize(fin)


C1Zip streamWriter - C#

C#

// save DataTable into compressed stream

BinaryFormatter bf = new BinaryFormatter();

FileStream fout = new FileStream("test.tmp", FileMode.Create);

C1ZStreamWriter compressor = new C1ZStreamWriter(fout);

bf.Serialize(compressor, DataTableOut);

fout.Close();

// read compressed data

FileStream fin = new FileStream("test.tmp", FileMode.Open);

C1ZStreamReader decompressor = new C1ZStreamReader(fin);

DataTable DataTableIn = bf.Deserialize(decompressor)


C1Zip streamWriter - Delphi

Delphi

var

bf: BinaryFormatter;

fout: FileStream;

compressor: C1ZStreamWriter;

fin: FileStream;

decompressor: C1ZStreamReader;

DataTableIn: DataTable;

begin

bf := BinaryFormatter.Create;

fout := FileStream.Create('test.tmp', FileMode.Create);

compressor := C1ZStreamWriter.Create(fout);

fin := FileStream.Create('test.tmp', FileMode.Open);

decompressor := C1ZStreamReader.Create(fin);

// save DataTable into compressed stream

bf.Serialize(compressor, DataTableOut);

fout.Close;

// read compressed data

DataTableIn := bf.Deserialize(decompressor);

end;


C1Zip streamWriter - Visual Basic

Visual Basic

' save DataTable into compressed stream

Dim bf As New BinaryFormatter()

Dim fout As New FileStream("test.tmp", FileMode.Create)

Dim compressor As New C1ZStreamWriter(fout)

bf.Serialize(compressor, DataTableOut)

fout.Close()

' read compressed data

Dim fin As New FileStream("test.tmp", FileMode.Open)

Dim decompressor As New C1ZStreamReader(fin)

Dim DataTableIn As DataTable = bf.Deserialize(decompressor)


C1Zip Test ZipFile - C#

C#

private void btnTest_Click(object sender, EventArgs e) btnTest.Click {

// test each entry

foreach (C1ZipEntry ze In m_Zip.Entries)

{

if (!ze.CheckCRC32())

{

MessageBox.Show("** Entry " + ze.FileName + " has errors.",

"C1Zip", MessageBoxButtons.OK, MessageBoxIcon.Error);

return;

}

}

// if we got here, everything is OK

MessageBox.Show("All entries passed CRC check", "C1Zip");

}


C1Zip Test ZipFile - Delphi

Delphi

procedure btnTest_Click(sender: System.Object; e: System.EventArgs);

var

ze: C1ZipEntry;

i: Integer;

begin

// test each entry

for i := 0 to m_Zip.Entries.Count - 1 do

begin

ze := m_Zip.Entries[i];

if Not ze.CheckCRC32 then

begin

MessageBox.Show('** Entry ' + ze.FileName + ' has errors.','C1Zip', MessageBoxButtons.OK, MessageBoxIcon.Error);

Exit;

end;

end;

// if we got here, everything is OK

MessageBox.Show('All entries passed CRC check','C1Zip');

end;


C1Zip Test ZipFile - Visual Basic

Visual Basic

Private Sub btnTest_Click(sender As Object, e As EventArgs) _

Handles btnTest.Click

' test each entry

Dim ze As C1ZipEntry

For Each ze In m_Zip.Entries

If Not ze.CheckCRC32() Then

MessageBox.Show("** Entry " & ze.FileName & " has errors.", _

"C1Zip", MessageBoxButtons.OK, MessageBoxIcon.Error)

Exit Sub

End If

Next

' if we got here, everything is OK

MessageBox.Show("All entries passed CRC check", "C1Zip")

End Sub


C1Zip Update Display - C#

C#

private void UpdateDisplay()

{

// remove any existing items

ListView1.Items.Clear();

// add each entry

foreach (C1ZipEntry ze in m_Zip.Entries)

{

// calculate compression amount

double pct = 0;

if (ze.SizeUncompressed > 0)

pct = 1 - ze.SizeCompressed / ze.SizeUncompressed;

// build listview item

string[] items = new string[4];

items[0] = ze.FileName;

items[1] = Format(ze.Date, "MM/dd/yy");

items[2] = Format(ze.SizeUncompressed, "#,##0");

items[3] = Format(ze.SizeCompressed, "#,##0");

items[4] = Format(pct, "00 %");

ListViewItem lvi = new ListViewItem(items);

// save ZipEntry into item tag

lvi.Tag = ze;

// add item to listview

ListView1.Items.Add(lvi);

}

// update UI

bool hasEntries = (Items.Count > 0);

btnExtract.Enabled = hasEntries;

btnRemove.Enabled = hasEntries;

btnTest.Enabled = hasEntries;

}


C1Zip Update Display - Delphi

Delphi

procedure UpdateDisplay;

var

ze: C1ZipEntry;

pct: Double;

items: array of string;

lvi: ListViewItem;

hasEntries: Boolean;

i: Integer;

begin

// update ListView control to show Zip file contents

// With ListView1

// remove any existing items

ListView1.Items.Clear;

// add each entry

for i := 0 to m_Zip.Entries.Count - 1 do

begin

ze := m_Zip.Entries[i];

// calculate compression amount

pct := 0;

if ze.SizeUncompressed > 0 then

begin

pct := 1 - ze.SizeCompressed / ze.SizeUncompressed;

end;

// build listview item

SetLength(items, 5);

items[0] := ze.FileName;

items[1] := Format(ze.Date,'MM/dd/yy');

items[2] := Format(ze.SizeUncompressed,'#,##0');

items[3] := Format(ze.SizeCompressed,'#,##0');

items[4] := Format(pct,'00 %');

lvi := ListViewItem.Create(items);

// save ZipEntry into item tag

lvi.Tag := ze;

// add item to listview

ListView1.Items.Add(lvi);

end;

// update UI

hasEntries := ListView1.Items.Count > 0;

btnExtract.Enabled := hasEntries;

btnRemove.Enabled := hasEntries;

btnTest.Enabled := hasEntries;

end;


C1Zip Update Display - Visual Basic

Visual Basic

Private Sub UpdateDisplay()

' update ListView control to show Zip file contents

' With ListView1

' remove any existing items

ListView1.Items.Clear()

' add each entry

Dim ze As C1ZipEntry

For Each ze In m_Zip.Entries

' calculate compression amount

Dim pct As Double = 0

If ze.SizeUncompressed > 0 Then

pct = 1 - ze.SizeCompressed / ze.SizeUncompressed

End If

' build listview item

Dim items(4) As String

items(0) = ze.FileName

items(1) = Format(ze.Date, "MM/dd/yy")

items(2) = Format(ze.SizeUncompressed, "#,##0")

items(3) = Format(ze.SizeCompressed, "#,##0")

items(4) = Format(pct, "00 %")

Dim lvi As ListViewItem = New ListViewItem(items)

' save ZipEntry into item tag

lvi.Tag = ze

' add item to listview

ListView1.Items.Add(lvi)

Next

' update UI

Dim hasEntries As Boolean = (ListView1.Items.Count > 0)

btnExtract.Enabled = hasEntries

btnRemove.Enabled = hasEntries

btnTest.Enabled = hasEntries

' End With

End Sub


C1Zip View File - C#

C#

private void btnView_Click(object sender, EventArgs e)

{

// get first selected item that is not a directory

C1ZipEntry ze;

foreach (ListViewItem lvi in ListView1.SelectedItems)

{

C1ZipEntry zeItem = lvi.Tag as C1ZipEntry;

if ((zeItem.Attributes && FileAttributes.Directory) == 0 )

{

ze = zeItem;

break;

}

}

// make sure we got something

if (ze == null )

{

MessageBox.Show("Sorry, no files to show...", "C1Zip");

return;

}

// read entry content into a string

Stream entry = ze.OpenReader();

StreamReader sr = new StreamReader(entry);

string entryText = sr.ReadToEnd();

entry.Close();

// make sure entry is not too big for MessageBox

if (entryText.Length > 16000 ) {

entryText = entryText.Substring(0, 16000);

}

// show entry in message box

MessageBox.Show(entryText, ze.FileName);

}


C1Zip View File - Delphi

Delphi

procedure btnView_Click(sender: System.Object; e: System.EventArgs);

var

ze: C1ZipEntry;

lvi: ListViewItem;

zeItem: C1ZipEntry;

entry: Stream;

sr: StreamReader;

entryText: String;

i: Integer;

begin

// get first selected item that is not a directory

ze := nil;

for i := 0 to ListView1.SelectedItems.Count - 1 do

begin

lvi := ListView1.SelectedItems[i];

zeItem := lvi.Tag;

if (zeItem.Attributes and FileAttributes.Directory) = 0 then

begin

ze := zeItem;

break;

end;

end;

// make sure we got something

if ze = nil then

begin

MessageBox.Show('Sorry, no files to show...','C1Zip');

exit;

end;

// read entry content into a string

entry := ze.OpenReader;

sr := StreamReader.Create(entry);

entryText := sr.ReadToEnd;

entry.Close;

// make sure entry is not too big for MessageBox

if entryText.Length > 16000 then

entryText := entryText.Substring(0, 16000);

// show entry in message box

MessageBox.Show(entryText, ze.FileName);

end;


C1Zip View File - Visual Basic

Visual Basic

Private Sub btnView_Click(sender As Object, e As EventArgs) Handles btnView.Click

' get first selected item that is not a directory

Dim ze As C1ZipEntry

Dim lvi As ListViewItem

For Each lvi In ListView1.SelectedItems

Dim zeItem As C1ZipEntry = lvi.Tag

If (zeItem.Attributes And _

FileAttributes.Directory) = 0 Then

ze = zeItem

Exit For

End If

Next

' make sure we got something

If ze Is Nothing Then

MessageBox.Show("Sorry, no files to show...", "C1Zip")

Exit Sub

End If

' read entry content into a string

Dim entry As Stream = ze.OpenReader()

Dim sr As StreamReader = New StreamReader(entry)

Dim entryText As String = sr.ReadToEnd()

entry.Close()

' make sure entry is not too big for MessageBox

If entryText.Length > 16000 Then

entryText = entryText.Substring(0, 16000)

End If

' show entry in message box

MessageBox.Show(entryText, ze.FileName)

End Sub


Declare a C1ZipFile Object - C#

C#

private C1ZipFile m_Zip;


Declare a C1ZipFile Object - Delphi

Delphi

private m_Zip: C1ZipFile;


Declare a C1ZipFile Object - Visual Basic

Visual Basic

Private m_Zip As C1ZipFile


Declare a C1Zip NameSpace - C#

C#

C1.C1Zip.C1Zip zip;


Declare a C1Zip NameSpace - Delphi

Delphi

var

zip: C1.C1Zip.C1Zip;


Declare a C1Zip NameSpace - Visual Basic

Visual Basic

Dim zip As C1.C1Zip.C1Zip


Initialize C1ZipFile Object - C#

C#

private void Form1_Load(object sender, EventArgs e) base.Load {

// create C1ZipFile member

m_Zip = new C1ZipFile();

}


Initialize C1ZipFile Object - Delphi

Delphi

procedure Form1_Load(sender: Object; e: EventArgs);

begin

// create C1ZipFile member

m_Zip := C1ZipFile.Create;

end;


Initialize C1ZipFile Object - Visual Basic

Visual Basic

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

' create C1ZipFile member

m_Zip = New C1ZipFile()

End Sub


Open C1ZipFile - C#

C#

private void btnOpen_Click(object sender, EventArgs e)

{

// show open file dialog

OpenFileDialog OpenFileDialog fo = new OpenFileDialog();

fo.FileName = "*.zip";

if (fo.ShowDialog() != DialogResult.OK ) return;

try

{

m_Zip.Open(fo.FileName);

}

catch

{

MessageBox.Show("Invalid ZIP file, please try again.");

}

// update display

UpdateDisplay();

}


Open C1ZipFile - Delphi

Delphi

procedure btnOpen_Click(sender: System.Object; e: EventArgs);

var

OpenFileDialog: OpenFileDialog;

begin

fo := OpenFileDialog.Create;

fo.FileName := '*.zip';

if (fo.ShowDialog <> DialogResult.OK) then

begin

try

m_Zip.Open(fo.FileName);

except

MessageBox.Show('Invalid ZIP file, please try again.');

end;

UpdateDisplay;

end;

end;


Open C1ZipFile - Visual Basic

Visual Basic

Private Sub btnOpen_Click(sender As Object, e As EventArgs) Handles btnOpen.Click

' show open file dialog

Dim fo As OpenFileDialog = New OpenFileDialog()

fo.FileName = "*.zip"

If fo.ShowDialog() <> DialogResult.OK Then Exit Sub

Try

m_Zip.Open(fo.FileName)

Catch

MessageBox.Show("Invalid ZIP file, please try again.")

End Try

' update display

UpdateDisplay()

End Sub


Untitled Document


Untitled Document

 E-mail sent to documentation@componentone.com is for documentation feedback only. We welcome any suggestions to help improve our documentation.