I have implemented a code that creates a zip file. The zip file gets successfully created but however when I manually (without code) try and check the contents of the zip file by unzipping it, I get an error saying No archive found
and the unzipping process stops.. Why is this problem occuring.
Here is my code
#include <QCoreApplication>
#include <QByteArray>
#include <QBitArray>
#include <QString>
#include <QDebug>
#include <QFile>
void Zip(QString filename , QString zipfilename);
int main(int argc, char *argv[]){
QCoreApplication a(argc, argv);
Zip("C:\\programs\\zipping_qt\\sample.txt",
"C:\\programs\\zipping_qt\\samples.zip");
qDebug() << "Done zipping";
return a.exec();
}
void Zip (QString filename , QString zipfilename){
QFile infile(filename);
QFile outfile(zipfilename);
infile.open(QIODevice::ReadOnly);
outfile.open(QIODevice::WriteOnly);
QByteArray uncompressedData = infile.readAll();
QByteArray compressedData = qCompress(uncompressedData,9);
outfile.write(compressedData);
infile.close();
outfile.close();
}