#Region Project Attributes
#ApplicationLabel: sftp test
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim sftp1 As SFtp
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim ListView1 As ListView
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Try
If FirstTime Then
'use real credentials!
sftp1.Initialize("sftp1", "Domingo Gonzalez", "12345", "192.168.1.71", 22)
sftp1.SetKnownHostsStore(File.DirRootExternal , "hosts.txt")
End If
Activity.LoadLayout("1")
AddInfo("Try send first file")
sftp1.UploadFile (File.DirRootExternal ,"1.jpg","/1.jpg")
'sftp1.List ("/ftp/*.*")
Catch
AddInfo (LastException)
End Try
End Sub
Sub Activity_Resume
sftp1.Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub sftp1_UploadCompleted (ServerPath As String, Success As Boolean)
Log(ServerPath & ", Succes=" & Success)
If Success = False Then
'upload incomplete?
Log(LastException.Message)
Msgbox(LastException.Message,"Error:")
End If
End Sub
Sub sftp1_CommandCompleted (Command As String, Success As Boolean, Reply As String)
AddInfo (Command & " success=" & Success & " " & Reply)
End Sub
Sub sftp1_PromptYesNo (Message As String)
Dim res As Int = Msgbox2(Message, "", "Yes", "", "No", Null)
'The next line might be a bit confusing. It is a condition.
'The value will be True if res equals to DialogResponse.POSITIVE.
sftp1.SetPromptResult(res = DialogResponse.POSITIVE)
End Sub
Sub sftp1_ShowMessage (Message As String)
AddInfo (Message)
End Sub
Sub sftp1_ListCompleted (ServerPath As String, Success As Boolean, Folders() As SFtpEntry, Files() As SFtpEntry)
If Success Then
Dim i As Long
For i = 0 To Files.Length -1
AddInfo (Files(i).Name)
Next
AddInfo ("List command completed")
Else
AddInfo ("List command error")
End If
End Sub
Sub AddInfo (msj As String )
ListView1.AddSingleLine(msj)
End Sub
Sub Button1_Click
sftp1.CloseNow
ExitApplication
End Sub