Hi Max (and others)

I have just found out how to do it.  All I needed was

 VStream := TFileStream.Create(AFilename, fmOpenRead);


and the component handles the rest.
The joys of learning a new component model !

Rob Martin
Software Engineer

phone +64 03 377 0495
fax   +64 03 377 0496
web www.chreos.com

Wild Software Ltd



Max Nilson wrote:
Robert martin asked:
On the FTP server I have

procedure TForm1.IdFTPServerCRCFile(ASender: TIdFTPServerContext;
  const AFileName: String; var VStream: TStream); var
    CRC     : TIdHashCRC32;
    fs      : TFileStream;
    Hash    : String;
begin
    CRC := TIdHashCRC32.Create;
    try
        fs := TFileStream.Create(AFilename, fmOpenRead);
        try
            Hash    := IntToStr(CRC.HashValue(fs));

            VStream := TMemoryStream.Create;
            VStream.Write(Hash, SizeOf(Hash));

I think the preceeding line should read:
             VStream.Write(Hash, Length(Hash));

As SizeOf will return you 4 bytes being the native size of the string type,
ie. a pointer.

        finally
            fs.Free;
        end;
    finally
        CRC.Free;
    end;

Cheers, Max.


_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi

_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to