I'm having another problem now.
Is there a way to get the data in a TMemoryStream object into a String; it seems to support multiple object types for the buffer parameter, but not String. When I use the code below, the output is not the string in the file, it's the right length, but the values are wrong... I've tried ANSI, unicode and UTF-8 encoding, i've tried with html and txt data files, i've tried PChar, Byte arrays and char arrays as buffers, and everytime I get a slightly different string of non-standard characters... If I use String as the buffer directly, it creates an empty string
At present I'm using:
procedure TForm1.Button1Click(Sender: TObject);
var
fStream : TMemoryStream;
fBuffer : PChar;
sResult : String;
begin
ftpClient.Host := 'ftp.fusiongroupuk.com';
ftpClient.Username := 'currentversion@fusiongroupuk.com';
ftpClient.Password := 'password';
try
ftpClient.Connect(True);
ftpClient.TransferType := ftBinary;
fStream := TMemoryStream.Create();
ftpClient.Get('ftpTest.txt', fStream);
fStream.Read(fBuffer,fStream.Size);
SetString(sResult,fBuffer, Length(fBuffer));
lstStatus.AddItem(sResult, nil);
except
on E : Exception do
ShowMessage(E.ClassName+' error raised, with message : '+E.Message);
end;
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
Offline 1,091 posts
since Jul 2006