Re: PutFile (myMemoryStream) - WeOnlyDo Discussion board

Re: PutFile (myMemoryStream) (General questions)

by Hal, Monday, December 12, 2011, 20:03 (4730 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]


Complete thread: