Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QuaZip Unzip Trouble



  • Hello everyone.
    I have the folowing code to unzip a .zip file with some (.exe .txt .pdf)
    But the only file that can be read after unzip is the txt file.
    The others files can't be opened (.pdf .exe) and it file size is wrong

    for (bool more = zip.goToFirstFile(); more; more = zip.goToNextFile()) {
    QString filePath = zip.getCurrentFileName();
    QuaZipFile zFile(zip.getZipName(), filePath);
    zFile.open(QIODevice::ReadOnly);
    QByteArray ba = zFile.readAll();
    zFile.close();
    QFile dstFile("C:/" + filePath);
    dstFile.open(QIODevice::WriteOnly | QIODevice::Text);
    dstFile.write(ba.data());
    dstFile.close();
    }


  • Lifetime Qt Champion

    Hi
    Try look for TextStreams and other class that might convert input :)



  • @mrjj

    Solve the problem loading the data is this way.
    QDataStream out(&dstFile);
    out.writeRawData(ba.data(), ba.size());

    And works like a charm!
    Thank you!


Log in to reply