tamir.sharpssh 的问题。

bustersword 2011-01-24 01:50:53
我用tamir.sharpssh连接SFTP,偶尔会出现Unable to write data to the transport connection,是什么问题呢?
...全文
296 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
bustersword 2011-01-24
  • 打赏
  • 举报
回复
谢谢楼上的,这方面的资料真少,而且就算找到,也是差不多的。
邋遢的土豆 2011-01-24
  • 打赏
  • 举报
回复
http://blog.csdn.net/changezhong/archive/2007/01/30/1498073.aspx
邋遢的土豆 2011-01-24
  • 打赏
  • 举报
回复

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;
}
}
}
}

bustersword 2011-01-24
  • 打赏
  • 举报
回复
没有人遇到过吗,操作SFTP类似的情况,也可以说说啊

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧