我需要使用sftp在服务器上发送文件,但它不起作用。 [英] I need to send file on server using sftp, but it is not work.

查看:77
本文介绍了我需要使用sftp在服务器上发送文件,但它不起作用。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I Need To Send File On Server Using SFTP, But It Is Not Work.
 
I have Use WinSCP And Get Error "Network error: Software caused connection abort"
 
my code is below
 
public static int Main()
{
try
{
// Setup session options
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = "",
UserName = "",
Password = "",
GiveUpSecurityAndAcceptAnySshHostKey = true,
//SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
};

using (Session session = new Session())
{
// Connect
session.Open(sessionOptions);

// Upload files
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;

TransferOperationResult transferResult;
//String filePath = Server.MapPath("Templates/3-FinancialAdvisor.pdf");
transferResult = session.PutFiles(@"C:\Users\keenans", "../Bin/WinSCP.exe", false, transferOptions);

// Throw on any error
transferResult.Check();

// Print results
foreach (TransferEventArgs transfer in transferResult.Transfers)
{
Console.WriteLine("Upload of {0} succeeded", transfer.FileName);
}
}





我的尝试:



i尝试使用所有SFTP客户端连接,但任何人都无法访问此文件而没有Filezilla。

FileZilla

WinSCP

WS_ftp

FireFTP



What I have tried:

i have Try To It Given All SFTP Client To Connect, But Any One Not Access This Credential Without Filezilla.
FileZilla
WinSCP
WS_ftp
FireFTP

推荐答案

请参阅以下链接以获取有关c#中SFTP实现的详细信息。

1. .NET :: WinSCP中的SFTP文件传输 [

title =新窗口> ^
]

2。 http://www.csidata.com/?page_id=2828

3. < a href =http://www.codeproject.com/Questions/544479/C-plussftpplusdownloadplusandplusupload> http://www.codeproject.com/Questions/544479/C-plussftpplusdownloadplusandplusupload
Refer the following link to get detailed information about SFTP implementation in c#.
1. SFTP file transfers in .NET :: WinSCP[
title="New Window">^
]
2. http://www.csidata.com/?page_id=2828
3. http://www.codeproject.com/Questions/544479/C-plussftpplusdownloadplusandplusupload


这篇关于我需要使用sftp在服务器上发送文件,但它不起作用。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆