我用tamir.sharpssh连接SFTP,偶尔会出现Unable to write data to the transport connection,是什么问题呢?

解决方案 »

  1.   

    没有人遇到过吗,操作SFTP类似的情况,也可以说说啊
      

  2.   


    using System;
    using Tamir.SharpSsh;namespace SFTP
    {
        /// <summary>
        /// Summary description for SFTPHelper.
        /// </summary>
        public class SFTPHelper
        {
            private SFTPHelper()
            {
                
            }        private SshTransferProtocolBase m_sshCp;        public bool Connected
            {
                get
                {
                    return m_sshCp.Connected;
                }
            }
            public SFTPHelper(SshConnectionInfo connectionInfo)
            {
                //
                //TODO: Check connectionInfo
                //            m_sshCp = new Sftp(connectionInfo.Host,connectionInfo.User);            if(connectionInfo.Pass != null) 
                {
                    m_sshCp.Password = connectionInfo.Pass;
                }            if(connectionInfo.IdentityFile != null) 
                {
                    m_sshCp.AddIdentityFile(connectionInfo.IdentityFile );
                }
            }        public void Connect()
            {
                if(!m_sshCp.Connected)
                {
                    m_sshCp.Connect();
                }
            }        public void Close()
            {
                if(m_sshCp.Connected)
                {
                    m_sshCp.Close();
                }
            }        public bool Upload(string localPath,string remotePath)
            {
                try
                {
                    if(!m_sshCp.Connected)
                    {
                        m_sshCp.Connect();
                    }
                    m_sshCp.Put(localPath, remotePath);                return true;
                }
                catch
                {
                    return false;
                }        }        public bool Download(string remotePath,string localPath)
            {
                try
                {
                    if(!m_sshCp.Connected)
                    {
                        m_sshCp.Connect();
                    }                m_sshCp.Get(remotePath,localPath);                return true;
                }
                catch
                {
                    return false;
                }
            }
        }
    }
      

  3.   

    http://blog.csdn.net/changezhong/archive/2007/01/30/1498073.aspx