OnDataFromClient and Tbytes

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

OnDataFromClient and Tbytes

Post by snorkel » Wed 05 Nov 2008 20:41

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

snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

Post by snorkel » Wed 05 Nov 2008 21:42

Nevermind,
found ScCLRClasses which has a encoding class with a getstring function.

FerCastro
Posts: 47
Joined: Mon 26 Jun 2006 17:32
Location: México City
Contact:

Post by FerCastro » Fri 14 May 2010 17:25

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 -

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 17 May 2010 07:47

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.

FerCastro
Posts: 47
Joined: Mon 26 Jun 2006 17:32
Location: México City
Contact:

Post by FerCastro » Mon 17 May 2010 15:26

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

FerCastro
Posts: 47
Joined: Mon 26 Jun 2006 17:32
Location: México City
Contact:

Post by FerCastro » Mon 17 May 2010 18:16

Thanks, it is solved, i missed one parameter.

ScSFTPClient.WriteFile(Handle, FileOffset, Buffer,0, length(cTextoArchivo));

Best regards!!

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 19 May 2010 08:27

Feel free to contact us if you have any further questions about SecureBridge.

Post Reply