文字数[1150文字] この記事は1分26秒で読めます.

C#SFTPでダウンロードするプログラムの作り方。

20161206

Logging


C#SFTPでダウンロードするプログラムの作り方。
いろいろ調べた結果、こんだけのコードでSFTPでダウンロードする事が
判明。タダシ!!ライブラリが必要なので下記のリンクからTamir.SharpSSH.dll
のライブラリを参照してあげてください。そうすることでSFTPのダウンロードが
可能になります。FTPでの接続方法とかは結構出回っていますが、SFTPの接続プログラムって
あまり落ちてません。ちなみに、その他のライブラリを使う方法にWinSCPのライブラリを
使う方法やSSH.Netのライブラリを使う方法があります。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Tamir.SharpSsh;
namespace ftp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Sftp sftp = new Sftp("192.168.11.1", "id", "pass");
            sftp.Connect();
            sftp.Get("/www/html/hoge.mp4", "C:\\Users\\hoge\\Documents\\hoge.mp4");
            sftp.Close();
            MessageBox.Show("キタ━━━━(゚∀゚)━━━━!!");
        }
    }
}

https://ja.osdn.net/projects/sfnet_sharpssh/downloads/SharpSSH/1.1.1.13/SharpSSH-1.1.1.13.bin.zip/

174 Views

著者名  @taoka_toshiaki

Profile
高知県在住の@taoka_toshiakiです、記事を読んで頂きありがとうございます.
数十年前から息を吸うように日々記事を書いてます.たまに休んだりする日もありますがほぼ毎日投稿を心掛けています😅.
SNSも使っています、フォロー、いいね、シェア宜しくお願い致します🙇.
SNS::@taoka_toshiaki

タグ

Collections.Generic, Documents, Form, FTP, hoge, InitializeComponent, object sender, quot, SFTP, Sftp sftp, sftp.Close, System.Text, users, using, using System.ComponentModel, using System.Drawing, using System.Linq, using System.Threading.Tasks, WinSCP, タダシ,