You do it by opening the receiving file before the transfer, writing all available bytes into that file on each call (of many) your readyRead() handler receives, and closing the file when the finished signal is received. If the files are guaranteed to be small, i.e. not exhaust memory, then you can simply wait for the finished() signal, check for errors, and read the entire file in one hit. No loops required.
You are also making the serious mistake of assuming that the file name arrives in one block that is exactly the size of the string you were expecting. This will almost never be the case and certainly cannot be relied on. You need a smarter protocol.
Bookmarks