Dart Requires Chilkat v11.0.0+
Dart
Unzip Text File to String
See more Zip Examples
Demonstrates how to open a .zip and extract the 1st file (assuming it's a text file) to a string variable.Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
final zip = CkZip();
try {
zip.openZip('qa_data/zips/EC16100.zip');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
// Get the 1st file in the .zip
final entry = CkZipEntry();
try {
zip.entryAt(0, entry);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
final fileContents = entry.unzipToString(0, 'utf-8');
print(fileContents);
}