This post was last edited by sgFengSu on 2019-1-1 10:51
The previous post did not add SFTP to it, so I wrote it separately here C# itself is a class or method that does not interact with SFTP, and you need to reference SSH.NET class library GitHub SHH.NET download address https://github.com/sshnet/SSH.NET This is the latest, if the download from other places is not easy to use, you can first see if it is a version problem, and the project itself is. .NET 4.0 requires a dll that supports 4.0 The contents of the downloaded file are shown in the figure
Then you can build your own class, many people have written it, you can search for it, and then I will upload it on the attachment (it was also written by someone else, I forgot where I downloaded it from). Whether uploading or downloading, you need to connect first, and then close the connection.
PS:SFTP默认端口 22 Oh, by the way, there is a difference between SFTP and FTP, don't confuse it. There is an extra S(SecureSecurity, compared to FTP, SFTP is more secure, but what is more secure is the sacrifice of performance, and the transfer rate will be slower. As long as SSH is enabled on the linux system, SFTP is also available, and there is no need to install it, while FTP needs to be installed separately
When uploading UploadFile, the following upload directory is the SFTP server folder directory + the name of the file to be uploaded.
Source code download:
Tourists, if you want to see the hidden content of this post, please Reply
|