#using <System.dll>
#using <System.IO.Compression.ZipFile.dll>
#using <System.IO.Compression.dll>
using namespace System;
using namespace System::IO;
using namespace System::IO::Compression;
int main()
{
String^ zipfile = "F:\\testzip\\test.zip";
String^ targetfolder = "F:\\testzip\\test";
FileStream^ f = gcnew FileStream(zipfile, System::IO::FileMode::Open);
ZipArchive^ zip = gcnew ZipArchive(f, System::IO::Compression::ZipArchiveMode::Read);
auto list = zip->Entries;
Console::WriteLine(list->Count);
for (size_t i = 0; i < list->Count; i++)
{
auto entry = list[i];
auto path = Path::Combine(targetfolder, entry->FullName);
Console::WriteLine(path);
auto streamentry = entry->Open();
auto dir = Path::GetDirectoryName(path);
if (!Directory::Exists(dir))
Directory::CreateDirectory(dir);
FileStream^ bw = gcnew FileStream(path, System::IO::FileMode::CreateNew);
streamentry->CopyTo(bw);
bw->Flush();
}
}
根据您的 visual-c++ 标签,没有标准方法 - 您可以这样做:
winapi中没有任何功能,我使用了一个更简单的版本没有麻烦https://github.com/kuba--/zip (简单但有效)。