Jump to content
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×