Re: How can I convert this method to be compatible with the latest Indy version?

Giganews Newsgroups
Subject: Re: How can I convert this method to be compatible with the latest Indy version?
Posted by:  Matthijs ter Woord (matthi…@terwoord.nl)
Date: Wed, 7 Dec 2005

Previously, you needed to wrap TStream descendants in a TIdStreamVCL. Now
you can just pass TStream descendants to Indy, so no need to instantiate an
LWrapper object.

"Stephane Wierzbicki" <swierzbic…@free.fr> wrote in message
news:3E7032F0A5E4E240swierzbic…@free.fr...
> Hi,
>
> I'm a little bit lost, I first move my prject from Indy 9 to Indy 10, I
> needed to change everything related with Stream. Now, I'm moving from
> Indy 10 to indy 10.1 and my code is broken.
>
> Here is one of a no more working method.
> Can someone be kind and point me what to change ? This would be vry
> friendly.
>
> I tried to change the TIdStreamVCL to TStream, but I can't get it working
!
>
> function
>
SendfileToServer(AIdTCPClient:TidTCPClient;AFilename,ASiteId:string):boolean
> ;
> var
> LWrapper : TIdStreamVCL;
> FileStream: TFileStream;
> LStreamSize : int64;
> Begin
> try
>            result:=false;
>            FileStream:= TFileStream.Create(AFilename,fmOpenRead or
> fmShareDenyWrite);
>              try
>                LWrapper := TIdStreamVCL.Create(FileStream);
>                try
>                  if AIdTCPClient.SendCmd('FILE'+'|'+
> extractfilename(AFilename) +'|'+IntToStr(LWrapper.VCLStream.Size)
> +'|'+ASiteID) <> 100 then
>                  begin
>                  // handle the error in SendCmd() as needed...
>                  ShowMessage(AIdTCPClient.LastCmdResult.Text.Text);
>                  end else
>                  begin
>                    AIdTCPClient.IOHandler.Write(LWrapper,0);
>                    if AIdTCPClient.GetResponse([]) <> 100 then
>                    begin
>                      // handle the error in GetResponse() as needed...
>                      result:=false;
>                      ShowMessage(AIdTCPClient.LastCmdResult.Text.Text);
>                    end else
>                    Begin
>                      result:=true;
>                    End;
>                  End;
>                finally
>                  FreeAndNil(LWrapper);
>                end;
>              finally
>                  FreeAndNil(FileStream);
>              end;
>          except
>          on E: Exception do
>            begin
>              // handle an unexpected error...
>              result:=false;
>              ShowMessage(E.Message);
>            end;
>          end;
> End;
>
> thank you

Replies

None

In response to

How can I convert this method to be compatible with the latest Indy version? posted by Stephane Wierzbicki on Wed, 07 Dec 2005