Results 1 to 2 of 2

Thread: Streams

  1. #1
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Streams

    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:
    [pascal]var Stream : TStringStream;
    begin
    Stream := TStringStream.Create('');

    GetFile('MyFile.txt', Stream);

    Memo1.Lines.LoadFromStream(Stream);

    Stream.Free;
    [/pascal]

    GetFile code:
    [pascal]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;[/pascal]
    NecroSOFT - End of line -

  2. #2
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Streams

    OMG, never mind.... I forgot the set position to 0 of the TStringStream

    see /////////////////////// FIX ///////////// in previous post
    NecroSOFT - End of line -

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •