000
05.12.2006, 09:47 Uhr
DDult
|
Hallo zusammen! Ich benutze Microsoft Visual Studio und programmiere in C++. Mit der GZipSteam Klasse kann ich eine einzelne Datei zippen. Wie kann ich einen Verzeichnisbaum zippen?? Bitte detaillierte Antworten, da ich noch recht neu beim programmieren bin. Hier der code:
void GZipCompressDecompress( String^ filename ) { Console::WriteLine( "Test compression and decompression on file {0}", filename ); FileStream^ infile; try { // Open the file as a FileStream object. infile = gcnew FileStream( filename,FileMode::Open,FileAccess::Read,FileShare::Read ); array<Byte>^buffer = gcnew array<Byte>((int)infile->Length); // Read the file to ensure it is readable. int count = infile->Read( buffer, 0, buffer->Length ); if ( count != buffer->Length ) { infile->Close(); Console::WriteLine( "Test Failed: Unable to read data from file" ); return; } infile->Close();
//MemoryStream^ ms = gcnew MemoryStream; FileStream^ fs = gcnew FileStream("C\temp\\test.gz,FileMode::Create,FileAccess::Write);
// Use the newly created memory stream for the compressed data. GZipStream ^ compressedzipStream = gcnew GZipStream( fs,CompressionMode::Compress,true ); Console::WriteLine( "Compression" ); compressedzipStream->Write( buffer, 0, buffer->Length );
// Close the stream. compressedzipStream->Close(); Console::WriteLine( "Original size: {0}, Compressed size: {1}", buffer->Length, fs->Length );
Vielen Dank im Voraus!! |