Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QuaZip Unzip Trouble
Forum Updated to NodeBB v4.3 + New Features

QuaZip Unzip Trouble

Scheduled Pinned Locked Moved Unsolved General and Desktop
quazip
3 Posts 2 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Helson
    wrote on last edited by
    #1

    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();
    }

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      H 1 Reply Last reply
      1
      • mrjjM mrjj

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

        H Offline
        H Offline
        Helson
        wrote on last edited by
        #3

        @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!

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved