PutFile (myMemoryStream) (wodSFTP / wodSFTP.NET / wodSFTPdll)
I am testing the SFTP component and doing a .PutFile with a memory stream. Between each letter is a NUL. Anyone do this previously and know how to handle this?
I am testing the SFTP component and doing a .PutFile with a memory stream. Between each letter is a NUL. Anyone do this previously and know how to handle this?
by woddrazen
, (5130 days ago) @ hal
Hi Hal,
Here is example how you can use memory stream inside wodSFTP.NET PutFile Method:
[code] Dim dataout As String
dataout = this is some text
Dim ms As System.IO.MemoryStream
ms = New System.IO.MemoryStream(System.Text.Encoding.ASCII.GetBytes(dataout))
sftp1.PutFile(ms, /home/test/testfile.txt )[/code]
Can you maybe try something like that and let us know how it goes?
Hope I helped.
Regards,
Drazen
by Hal
, (5127 days ago) @ woddrazen
I have narrowed this issue down to when the file being transfered is in a format other than ASCII.
Is there something I need to do different for transfering unicode?
by woddrazen
, (5127 days ago) @ Hal
Hal
You only need to change encoding from ASCII to Unicode inside my code. Does it work like that maybe?
Drazen
by Hal
, (5127 days ago) @ woddrazen
When I set to UNICODE is when I get the [NUL]
for example:
t[NUL]e[NUL]s[NUL]t[NUL]
by woddrazen
, (5127 days ago) @ Hal
Hal
Can you show us maybe your code snippet?
Drazen
by Hal
, (5127 days ago) @ woddrazen
This is my function
[code]Public Function Send(ByVal FileData As MemoryStream, ByVal UserName As String, ByVal Password As String, ByVal Server As String, ByVal Port As Integer, ByVal OutputPath As String)
Dim myFT As New SFTP
Dim toReturn As Boolean
Try
myFT.Hostname = Server
myFT.Login = UserName
myFT.Password = Password
myFT.RemotePath = OutputPath
myFT.Port = Port
myFT.Blocking = True
myFT.Connect()
myFT.TransferMode = SFTP.TransferModes.Binary
myFT.PutFile(FileData)
FileData.Close()
toReturn = True
Catch ex As Exception
toReturn = False
Finally
myFT.Dispose()
End Try
Return toReturn
End Function[/code]
This is my calling event
[code]Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
SFTPFileTransfer.Send(New IO.MemoryStream(System.Text.Encoding.Unicode.GetBytes(TextBox1.Text)), _
user , pw , server , 22, _
String.Format( /path/TestFilename{0}.txt , DateTime.Now.ToString( yyyyddMMHHmmss )))
End Sub[/code]
by woddrazen
, (5127 days ago) @ Hal
Hal,
Can you please change encoding from Unicode to UTF8 (this is unicode also).
Something like this:[code]System.Text.Encoding.UTF8.GetBytes(TextBox1.Text)[/code]
Does that help maybe?
Drazen
by Hal
, (5127 days ago) @ woddrazen
UTF8 produced the expected results. Thanks.

May I say how nice it is to work with components so complete and self-explanatory that using them in my application is as instinctive as though I wrote them myself?

I would highly recommend this to anyone who needs a good quality SFTP solution.

Your component works really great. With minor effort I have been able to convert my delphi application...

We have recently completed a large 1200+ location project where reliable Telnet and SSH connectivity was required. wodSSH worked flawlessly and allowed our staff to complete our project ontime and within budget.

I can only hope I will have the pleasure to work with other products by "We Only Do" in the future.

We have recently completed a large 1200+ location project where reliable Telnet and SSH connectivity was required. wodSSH worked flawlessly and allowed our staff to complete our project ontime and within budget.

Fantastic product by the way, it has helped us tremendously on a daily basis. Keep up the good work.

Many thanks for your excellent support service. I can see why you have a long list of excellent testimonials on your website.

I would highly recommend this to anyone who needs a good quality SFTP solution.

Thank you very much for the rapid responses. I was a little nervous about dealing with a company that is on a different continent from me. You have proven my concerns to be unfounded.

