Page 1 of 1
OnDataFromClient and Tbytes
Posted: Wed 05 Nov 2008 20:41
by snorkel
What is the best way to handle tbytes in Delphi 2007
In Delphi 2009, you can use tencoding to convert to string.
If I am sending strings from the client to the server what is the best way to pull them out of the tbytes array returned in OnDataFromClient?
Thanks,
Snorkel
Posted: Wed 05 Nov 2008 21:42
by snorkel
Nevermind,
found ScCLRClasses which has a encoding class with a getstring function.
Posted: Fri 14 May 2010 17:25
by FerCastro
Hello Snorkel
I have been working with the demo version of SB and i have found some problems working with TBytes, trying to write text to the server.
Actually I found the function : Encoding.ASCII.GetString used to convert from tbytes to string, but I want the "opposite" function (i guess it has to be one function).
The problem is, i can not found the ScCLRClasses file, i guess because the demo version.
Is there any solution?
Thanks and best regrads.
- D2007 -
Posted: Mon 17 May 2010 07:47
by Dimon
To solve the problem you can use the Encoding.ASCII.GetBytes funtion.
You can find the ScCLRClasses.dcu unit by the following path: SB_InstDir\Lib\ScCLRClasses.dcu
SB_InstDir is the SecureBridge installation directory on your computer.
Posted: Mon 17 May 2010 15:26
by FerCastro
Thanks Dimon,
I have compiled with the function you sent me but I get the same result.
This is my code:
Code: Select all
cTextoArchivo := '';
FileOffset := 0;
// This is the text I will write in the new txt file in the SFTP server (actually is ascii)
cTextoArchivo := oClaseManejoArchivos.GetArchivo(slArchivos[nCicloArchivos]);
if cTextoArchivo '' then
Begin
Buffer := Encoding.ASCII.GetBytes(cTextoArchivo);
End;
if cTextoArchivo '' then
begin
try
Handle := ScSFTPClient.OpenFile(GetRootDir + slArchivos[nCicloArchivos], [foCreate, foRead, foWrite]);
ScSFTPClient.WriteFile(Handle, 0, Buffer, Sizeof(Buffer));
finally
ScSFTPClient.CloseHandle(Handle);
end;
end;
But when i open the file in the SFTP server I get the following;
hý'
It seems (i don't know exactly) there is something with unicode.
Thanks and best regards
Posted: Mon 17 May 2010 18:16
by FerCastro
Thanks, it is solved, i missed one parameter.
ScSFTPClient.WriteFile(Handle, FileOffset, Buffer,0, length(cTextoArchivo));
Best regards!!
Posted: Wed 19 May 2010 08:27
by Dimon
Feel free to contact us if you have any further questions about SecureBridge.