A potential solution would be to have some meta-data in the transmission, such as the length of the filename/size in bytes. The structure of the transmission could look like:
|num_bytes_in_file_name|num_bytes_in_size_of_file|filename_in_bytes ....|size_in_bytes...|data...|
The purpose of tracking the number of bytes is so that the index interval can be found. The first value of the byte array gives you the length of the filename, the second value the size of the file. Then, index 2 though 2+num_bytes_in_file_name contain the filename, 2+num_bytes_in_file_name through 2+num_bytes_in_file_name+num_bytes_in_size_of_file would contain the size of the file, and everything beyond would be the data.
For example:
index: [0] [1] [2] [3] [4] [5] [6-...]
|(3)|(1)|'c'|'a'|'t'|10|(data)|
Then you know that the name is on the interval of [2-4], the size is the first value after that [5], and everything beyond [6-...] is the data.
namestart[Filename]nameendpattern.