NecroDOME
11-03-2007, 08:06 PM
Hi there,
Im trying to copy a simple stream.
Here's what I do:
I create TFileStream( with a txt file )
I Create a TStringStream( '' )
Next I copy TFileStream to the TStringStream ( TStringStream.CopyFrom(TFileStream) )
The size of TStringStream equals the size of TFileStream
I grab a memo and copy the TStringStream to the memo (Memo1.Lines.LoadFromStream( TFileStream ) )
Why is this not working?
Code:
var Stream : TStringStream;
begin
Stream := TStringStream.Create('');
GetFile('MyFile.txt', Stream);
Memo1.Lines.LoadFromStream(Stream);
Stream.Free;
GetFile code:
var FileStr: TFileStream;
begin
Result := False;
try
FileStr := TFileStream.Create(FDataPath + FileName, fmOpenRead or fmShareDenyWrite);
Stream.CopyFrom( FileStr, 0 );
///////////////////////////// FIX /////////////
Stream.Position := 0;
Result := True;
finally
FileStr.Free;
end;
Im trying to copy a simple stream.
Here's what I do:
I create TFileStream( with a txt file )
I Create a TStringStream( '' )
Next I copy TFileStream to the TStringStream ( TStringStream.CopyFrom(TFileStream) )
The size of TStringStream equals the size of TFileStream
I grab a memo and copy the TStringStream to the memo (Memo1.Lines.LoadFromStream( TFileStream ) )
Why is this not working?
Code:
var Stream : TStringStream;
begin
Stream := TStringStream.Create('');
GetFile('MyFile.txt', Stream);
Memo1.Lines.LoadFromStream(Stream);
Stream.Free;
GetFile code:
var FileStr: TFileStream;
begin
Result := False;
try
FileStr := TFileStream.Create(FDataPath + FileName, fmOpenRead or fmShareDenyWrite);
Stream.CopyFrom( FileStr, 0 );
///////////////////////////// FIX /////////////
Stream.Position := 0;
Result := True;
finally
FileStr.Free;
end;