SFTP Using Chilkat Active component
2016-09-22 11:17
519 查看
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
End Sub
Private Sub sftp_PercentDone(ByVal percent As Long, abort As Long)
Caption = Caption & "," & percent
End Sub
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
相关文章推荐
- 关于实现了接口BeanPostProcessor 和 接口FactoryBean 的注意事项
- PHP 源码加密 (zendGuard和ionCube)
- Php5.5新特性 Generators详解
- PHP使用星号隐藏用户名,手机和邮箱的实现方法
- 在PHP中使用协程实现多任务调度
- laravel 二级分类方法与使用
- 一步一步制作yaffs/yaffs2根文件系统(四)
- tpc-ds99 工具使用
- PHPStorm 和 WebStorm的正确打开方式
- RabbitMQ入门(PHP语言描述)
- 在ubantu14下使用composer安装laravel的记录
- PHP实现执行定时任务的几种思路详解
- Yii2简单地址美化并隐藏index.php
- PHP定时器实现每隔几秒运行一次
- PHP字符串函数strtr
- php读取出字符串中的img标签中的图片路径
- php中二分法查找算法实例分析
- NTP 服务器配置
- PHP实现异步调用方法研究
- 使用gitpage和hexo开发你自己的博客更新