Its a bit late - so if this doesn't work don't kill me, but here it goes :
 
Q1 := TFileStream.Create(curDir + 'Qtop.doc',fmOpenRead or fmShareDenyWrite);
Q2 := TFileStream.Create(curDir + 'Qbody.doc',fmOpenRead or fmShareDenyWrite);
Q3 := TFileStream.Create(curDir + 'Qdone.doc',fmCreate or fmShareDenyWrite);
 
Q3.CopyFrom( Q1, 0 );
Q3.CopyFrom( Q2, 0 );
Q3.Free;
Q2.Free;
Q1.Free;
 
Ie, you are saying to Q3, copy the contents of the stream in the parameter.  The second parameter - 0 - says that the stream you are copying from should have its position reset before the copy, and the entire stream should be read.
 
Your code copies Q3 into a TFileStream instance with no Reference Variable.  Since Q3 hasn't been created this could be a problem :-)
 
You can also use TMemoryStream to load into - ie make Q3 a memorystream, and then use the TmemoryStream SaveToFile method after you have streamed in the data from the other two files using.  Don't use the loadfromfile method however because it empties the receiving stream, and therefore two copies won't work.
 
----- Original Message -----
From: Tony Arcus
Sent: Tuesday, April 11, 2000 9:45 PM
Subject: [DUG]: Newbie Question re TFileStream

Once I have a file in a TFileStream
 
  Q1 := TFileStream.Create(curDir + 'Qtop.doc',fmOpenRead or fmShareDenyWrite);
  Q2 := TFileStream.Create(curDir + 'Qbody.doc',fmOpenRead or fmShareDenyWrite);
 
How do I join the two together so I can out put it as one file
 
  with TFileStream.Create(curDir + 'Qdone.doc',fmCreate or fmShareExclusive) do try
    CopyFrom(Q3, Q3.Size);
  finally
    Free;
  end;
(from Tony, a DUG Lurker)
 

 

Reply via email to