• SFTP Using Chilkat Active component


    https://www.example-code.com/vb6/sftp_uploadBandwidthThrottle.asp

    Private Sub Command1_Click()
    ' Important: It is helpful to send the contents of the
    ' sftp.LastErrorText property when requesting support.

    ' Dim sftp As New ChilkatSFtp

    '  Any string automatically begins a fully-functional 30-day trial.
    Dim success As Long
    success = sftp.UnlockComponent("Anything for 30-day trial")
    
    If (success <> 1) Then
        Text1.Text = Text1.Text & sftp.LastErrorText & vbCrLf
        Exit Sub
    End If
    
    '  Set some timeouts, in milliseconds:
    sftp.ConnectTimeoutMs = 15000
    sftp.IdleTimeoutMs = 15000
    
    '  Connect to the SSH server.
    '  The standard SSH port = 22
    '  The hostname may be a hostname or IP address.
    Dim port As Long
    Dim hostname As String
    'hostname = "www.my-ssh-server.com"
    hostname = "127.0.0.1"
    port = 22
    success = sftp.Connect(hostname, port)
    If (success <> 1) Then
        Text1.Text = Text1.Text & sftp.LastErrorText & vbCrLf
        Exit Sub
    End If
    
    '  Authenticate with the SSH server.  Chilkat SFTP supports
    '  both password-based authenication as well as public-key
    '  authentication.  This example uses password authenication.
    'success = sftp.AuthenticatePw("myLogin", "myPassword")
     success = sftp.AuthenticatePw("wgscd1", "111111")
    
    
    If (success <> 1) Then
        Text1.Text = Text1.Text & sftp.LastErrorText & vbCrLf
        Exit Sub
    End If
    
    '  After authenticating, the SFTP subsystem must be initialized:
    success = sftp.InitializeSftp()
    If (success <> 1) Then
        Text1.Text = Text1.Text & sftp.LastErrorText & vbCrLf
        Exit Sub
    End If
    
    '  Limit the transfer rate (bandwidth throttle) to 64K per second.
    sftp.BandwidthThrottleUp = 65536
    
    '  Upload from the local file to the SSH server.
    '  Important -- the remote filepath is the 1st argument,
    '  the local filepath is the 2nd argument;
    Dim remoteFilePath As String
    remoteFilePath = "hamlet.xml"
    Dim localFilePath As String
    localFilePath = "c:/temp/hamlet.xml"
    success = sftp.UploadFileByName(remoteFilePath, localFilePath)
    If (success <> 1) Then
        Text1.Text = Text1.Text & sftp.LastErrorText & vbCrLf
        Exit Sub
    End If
    
    Text1.Text = Text1.Text & "Success." & vbCrLf
    
    
      success = sftp.DownloadFileByName("TrackMM5--.exe", "c:/temp/TrackMM5--.exe")
    
    If (success <> 1) Then
        Text1.Text = Text1.Text & sftp.LastErrorText & vbCrLf
        Exit Sub
    End If
     Text1.Text = Text1.Text & "Download File Success." & vbCrLf
    

    End Sub

    Private Sub sftp_PercentDone(ByVal percent As Long, abort As Long)
    Caption = Caption & "," & percent

    End Sub

  • 相关阅读:
    记住密码功能
    android 对软键盘显示和消失,EditView的焦点获取事件进行监听
    Intent可以传递的数据
    是否有网络
    关于6.0闪退问题
    关于Android Studio使用高德地图地位
    CentOS 配置防火墙操作实例(启、停、开、闭端口)CentOS Linux-FTP/对外开放端口(接口)TomCat相关
    docker学习读书笔记-一期-整理
    阿里云https免费证书配置-包教会
    Dizcuz站点部署-包教会
  • 原文地址:https://www.cnblogs.com/wgscd/p/5895557.html
Copyright © 2020-2023  润新知