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. [Solved] How to read & write binary file from internet?
QtWS25 Last Chance

[Solved] How to read & write binary file from internet?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 3.4k Views
  • 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.
  • Z Offline
    Z Offline
    zither
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      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.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0

      • Login

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