Delphi Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Delphi Examples

Bounced Mail
Bz2
Character Encoding
CSV
DKIM / DomainKey
Digital Certificates
Digital Signatures
DH Key Exchange
DSA
Email
Email Object
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
NTLM
POP3
RSA
S/MIME
SMTP
Socket
Spider
SFTP
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression

More Examples...
Byte Array
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
Bzip2
LZW

Type Conversion

 

Article: Understanding COM References in Delphi

Unzip / Inflate a Text File into an In-Memory String

Download Chilkat Zip ActiveX (includes objects for .zip, .gz, .bz2, and .Z)

Demonstrates how to unzip a text file into an in-memory string.

// Shows how to open a zip and access the contents of a text
// file.
procedure TForm1.Button9Click(Sender: TObject);
var
  i : Integer;
  success : Integer;
  entry: IChilkatZipEntry2;
  fileContents: WideString;
  addCr: Integer;

begin
  ChilkatZip21.UnlockComponent('anything for 30-day trial');

  // Open a zip.
  success := ChilkatZip21.OpenZip('test.zip');
  if (success = 0) then
    begin
      ChilkatZip21.SaveLastError('zipErrorLog.txt');
      ShowMessage(ChilkatZip21.LastErrorText);
    end
  else
    begin
        Memo1.Lines.Clear();

        // Get the test.txt file.
        entry := ChilkatZip21.FirstMatchingEntry('*test.txt');

        // InflateToString3 returns a Unicode string.
        // If the text file within the zip contains text in a different
        // character encoding, we indicate it so the encoding conversion
        // takes place.  This allows for text files in any character encoding
        // to be retrieved as Unicode.
        fileContents := entry.InflateToString3('iso-8859-1');

        // InflateToString2 returns a Unicode string, assuming the text file
        // contained characters in the ANSI encoding.
        fileContents := entry.InflateToString2();

        // InflateToString returns a Unicode string, assuming the text file
        // contained characters in the ANSI encoding.   If addCr is set to 1,
        // line endings will be converted to CRLFs if necessary.
        addCr := 1;
        fileContents := entry.InflateToString(addCr);

        Memo1.Text := fileContents;
    end;

end;

 

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2010 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Email Component · XML Parser