Jump to content
Registration disabled at the moment Read more... ×
AndrewHoward

What's the equivalent of this ?

Recommended Posts

Hi,

What's the equivalent of this code in C# ?

procedure FetchFromIStream( myStream : TStream ; myIStream : IStream ) ;
var
   TOS : TOLEStream ;
begin
   TOS:=TOLEStream.Create(myIStream) ;
   try
      TOS.position:=0 ;
      myStream.position:=0 ;
      myStream.copyFrom(TOS,TOS.Size) ;
      myStream.Position:=0 ;
      TOS.position:=0 ;
    finally
      FreeAndNil(TOS);
   End ;
end ;

TIA

Share this post


Link to post

There isn't one, at least not natively.  You would have to write your own wrappers, either to wrap a myStream inside of an IStream and then call myIStream.CopyTo(), or else wrap myIStream inside of a System.IO.Stream and then call myStream.CopyTo().

 

A simpler way is to just call myIStream.Read() and myStream.Write() in a loop until there is nothing left to read from myIStream.  No wrappers needed, just a local byte[] array.

Edited by Remy Lebeau

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×