Unfortunately that doesn't work. The WriteBuffer is expecting a point. When I use the reference/dereference (^,@) Delphi won't even compile.
FileStream.WriteBuffer(fil
FileStream.WriteBuffer(@fi
Main Topics
Browse All TopicsI have a SOAP object that is handing back a TDynByteArray (aka Array of Byte) that is a file.
I want to save this array to a TFileStream. So far I have been able to do it, but it just seems wrong - I am converting the Byte array to a String, and using the TFileStream.WriteBuff(stri
Should I not be able to do the following:
bytesArrayFile:=SOAPObject
count:=Length(bytesArrayFi
MIMEString:=BytesToString(
FileStream:=TFileStream.Cr
// THE FOLLOWING LINE OF CODE WORKS - BUT I DON'T THINK I SHOULD BE
// CONVERTING THE BYTE ARRAY TO STRING AND THEN SAVING IT - COULD
// HAVE CONVERSION ISSUES.
FileStream.WriteBuffer(PCh
// THE FOLLOWING LINES ARE THINGS I HAVE TRIED - THEY REPLACE THE .WriteBuffer line above
pos:=FileStream.WriteBuffe
// THIS LOOP WORKS - BUT IT IS REALLY, REALLY SLOW.
for i:= 0 to (count - 1) do begin
FileStream.Write(bytesArra
end;
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Unfortunately that doesn't work. The WriteBuffer is expecting a point. When I use the reference/dereference (^,@) Delphi won't even compile.
FileStream.WriteBuffer(fil
FileStream.WriteBuffer(@fi
well, i got it work this way, maybe a bit clumsy
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TDynByteArray = array of Byte;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender
var
b : TDynByteArray;
i : Integer;
fs : TFileStream;
begin
setlength(b,1000);
for i := 0 to high(b) do
b[i] := ord('A');
fs := TFileStream.Create('D:\Byt
try
fs.WriteBuffer(pointer(b)^
finally
fs.free;
end;
end;
end.
meikl ;-)
I have had more success using the First member of a Dynamic array in file stream read and writes , instead of the Pointer Reference to the Dynamic array. . . maybe
FileStream.Write(bytesArra
// although the bytesArrayFile[0] is a single byte, the method does not care, as this is just the starting point to read from
Business Accounts
Answer for Membership
by: kretzschmarPosted on 2004-03-02 at 05:11:11ID: 10494520
hmm just a guess
r(bytesArr ayFile^,Dy nArrayLeng th(bytesAr rayFile);
r(@bytesAr rayFile,Dy nArrayLeng th(bytesAr rayFile);
bytesArrayFile is just a pointer, which points to the beginning
of the memory location of your array
if so, then this change may work
pos:=FileStream.WriteBuffe
or also
pos:=FileStream.WriteBuffe
well just guessing,
a test may cause an acces-violation
meikl ;-)