Copying data for file attachments results in zero byte file
I have some code that copies some file attachments from one entity to another. The code simply opens an EntitySchemaQuery to read the files, then creates the file records on the other entity. To copy the file data, I am doing:
However, the new file attachment record always only have a zero bytes file (no data is actually copied).
Does anyone know why this is the case? My assumption is that by reading the file record, the binary Data column isn't actually loaded in the entity. Do I need to do something extra to get the Data column contents?