[Solved] How to read & write binary file from internet?
-
Dear all,
I try to read & write binary file from internet using the following code
@QNetworkReply *reply;
QFile writeFile("test.exe");
if (writeFile.open(QIODevice::WriteOnly)){
QDataStream write(&writeFile;);
write << reply->readAll();
writeFile.close();
}
@
But, it add 4 extra bytes at the header of .exe file.
I try to use QDataStream::writeRawData ( const char * s, int len )
But how can I know the size of file from QNetworkReply *reply?Plz help
Thanks to all -
QNetworkReply inherits from QIODevice "size":http://doc.qt.nokia.com/4.7/qiodevice.html#size That is what you are looking for. If this is not sufficient, you need to handle externally.