Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Unzip / Inflate a Text File into an In-Memory StringDemonstrates 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-2008 Chilkat Software, Inc. All Rights Reserved.