您好,欢迎光临本网站![请登录][注册会员]  
文件名称: Open Ftp SSH Tools
  所属分类: VB
  开发工具:
  文件大小: 919kb
  下载次数: 0
  上传时间: 2011-03-22
  提 供 者: wang*****
 详细说明: 安全的FTP传输 Imports Org.Mentalis.Security.Ssl Imports Org.Mentalis.Security.Certificates Imports Org.Mentalis.Security.Cryptography Imports System Imports System.IO Imports System.Exception 'Imports Tamir.SharpSsh.java 'Imports Tamir.SharpSsh Imports SharpSSH_EXD Public Class SFTPHelper Private Sub New() End Sub Private m_sshCp As SshTransferProtocolBase Public ReadOnly Property Connected() As Boolean Get Return m_sshCp.Connected End Get End Property Public Sub New(ByVal c onnectionInfo As SshConnectionInfo) m_sshCp = New Sftp(connectionInfo.Host, connectionInfo.User) If (Not connectionInfo.Pass Is Nothing) Then m_sshCp.Password = connectionInfo.Pass End If If Not connectionInfo.IdentityFile Is Nothing Then m_sshCp.AddIdentityFile(connectionInfo.IdentityFile) End If End Sub Public Sub Connect() If (m_sshCp.Connected = False) Then Try m_sshCp.Connect(10022) ' m_sshCp.Connect() ' Dim i As Integer = m_sshCp.Port Catch ex As System.Exception ' Dim str As String = ex.ToString ' Dim a As Integer = 0 m_sshCp.Close() End Try End If End Sub Public Sub Close() If (m_sshCp.Connected) Then m_sshCp.Close() End If End Sub Public Function Upload(ByVal localPath As String, ByVal remotePath As String) As String Try If (m_sshCp.Connected = False) Then m_sshCp.Connect(10022) End If Try m_sshCp.Put_resume(localPath, remotePath) 'm_sshCp.RemoveFile(remotePath) ' Return "Remote File has already exists. delete file" Catch ex As Tamir.SharpSsh.jsch.SftpException m_sshCp.RemoveFile(remotePath) Return "Remote File has already exists. delete file" End Try Return "" Catch ex As Exception Return ex.Message End Try End Function Public Function Download(ByVal remotePath As String, ByVal localPath As String) As Boolean Try If (m_sshCp.Connected = False) Then m_sshCp.Connect(10022) End If m_sshCp.Get(remotePath, localPath) Return True Catch Return False End Try End Function Public Function CheckFileLength(ByVal filePath As String) As Long Try 'Dim stream As New Tamir.SharpSsh.SshStream(filePath.Replace(".TMP", ".TXT"), m_sshCp.Username, m_sshCp.Password) 'Return stream.Length If (m_sshCp.Connected = False) Then m_sshCp.Connect(10022) End If Return m_sshCp.GetFileLength(filePath) Catch ex As Exception Dim str As String = ex.ToString End Try Return 0 End Function Public Sub SetFileLength(ByVal filePath As String) 'set 0 Try 'Dim stream As New Tamir.SharpSsh.SshStream(filePath.Replace(".TMP", ".TXT"), m_sshCp.Username, m_sshCp.Password) 'Return stream.Length If (m_sshCp.Connected = False) Then m_sshCp.Connect(10022) End If m_sshCp.SetFileLength(filePath) Catch ex As Exception Dim str As String = ex.ToString End Try End Sub Public Function RenameFile(ByVal oldPath As String, ByVal newPath As String) As Boolean Dim blnResult As Boolean = False Try If (m_sshCp.Connected = False) Then m_sshCp.Connect(10022) End If m_sshCp.RenameFile(oldPath, newPath) blnResult = True Catch ex As Exception blnResult = False End Try Return blnResult End Function End Class Public Class SshConnectionInfo Private _user As String Private _pass As String Private _host As String Private _identityFile As String Public Property User() As String Get Return _user End Get Set(ByVal value As String) _user = value End Set End Property Public Property Pass() As String Get Return _pass End Get Set(ByVal value As String) _pass = value End Set End Property Public Property Host() As String Get Return _host End Get Set(ByVal value As String) _host = value End Set End Property Public Property IdentityFile() As String Get Return _identityFile End Get Set(ByVal value As String) _identityFile = value End Set End Property End Class ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: OpenFtp SSHTools
 输入关键字,在本站1000多万海量源码库中尽情搜索: