C++ Poco::Zip压缩/解压缩

C++ Poco::Zip压缩/解压缩,c++,compression,poco-libraries,C++,Compression,Poco Libraries,在使用Poco::Zip成功压缩/解压缩后,我发现无法解压缩使用压缩方法压缩的.Zip文件,反之亦然。但是我可以使用其他工具(如7z或WinRAR)解压缩我的zip文件,当然,如果我使用WinRAR或7z压缩zip文件,我可以使用我的解压缩方法解压缩zip文件。我不知道这里怎么了 以下是我的压缩方法: void ZipFile(string source, string target){ Poco::File aFile(source); if (aFil

在使用Poco::Zip成功压缩/解压缩后,我发现无法解压缩使用压缩方法压缩的.Zip文件,反之亦然。但是我可以使用其他工具(如7z或WinRAR)解压缩我的zip文件,当然,如果我使用WinRAR或7z压缩zip文件,我可以使用我的解压缩方法解压缩zip文件。我不知道这里怎么了

以下是我的压缩方法:

void ZipFile(string source, string target){
        Poco::File aFile(source);
            if (aFile.exists())
            {
                if (aFile.isDirectory())
                {
                    Poco::Path sourceDir(source);
                    sourceDir.makeDirectory();
                    c.addRecursive(sourceDir, Poco::Zip::ZipCommon::CompressionMethod::CM_DEFLATE,
                        Poco::Zip::ZipCommon::CL_NORMAL, false);
                }
                else if (aFile.isFile())
                {
                    Poco::Path p(aFile.path());
                    c.addFile(p, p.getFileName(), Poco::Zip::ZipCommon::CompressionMethod::CM_AUTO,
                        Poco::Zip::ZipCommon::CL_NORMAL);
                }
            }
    }
我的解压方法是:

void UnZipFile(string source, string target)
{
    _log.StartMethod("UnZipFile");
    std::ifstream inp("C:/Users/Emotive/Desktop/a.zip", std::ios::binary);
    Poco::Path targetDir(target);
    Poco::Zip::Decompress dec(inp, targetDir, true, true);
    // if an error happens invoke the ZipTest::onDecompressError method
    //dec.EError += Poco::Delegate<ZipTest, std::pair<const Poco::Zip::ZipLocalFileHeader, const std::string> >(this, &ZipTest::onDecompressError);
    dec.decompressAllFiles();
    //dec.EError -= Poco::Delegate<ZipTest, std::pair<const Poco::Zip::ZipLocalFileHeader, const std::string> >(this, &ZipTest::onDecompressError)
    inp.close();
}
void UnZipFile(字符串源、字符串目标)
{
_log.StartMethod(“UnZipFile”);
std::ifstream inp(“C:/Users/Emotive/Desktop/a.zip”,std::ios::binary);
路径targetDir(目标);
Poco::Zip::解压缩dec(inp,targetDir,true,true);
//如果发生错误,请调用ZipTest::onDecompressError方法
//dec.EError+=Poco::Delegate(this,&ZipTest::ondecompressorr);
dec.解压缩所有文件();
//dec.EError-=Poco::Delegate(this,&ZipTest::ondecompressorr)
inp.close();
}

您会遇到什么错误?您了解我的情况吗?我真的不知道具体的错误是什么。我真的不知道哪里出了问题,因为如果我解压缩一个zip文件,我以前用WINRAR或7z压缩过,它成功了。唯一不成功的情况是我用Poco压缩,用Poco解压。