3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

VBでSFTP接続しファイルアップロードする方法

Last updated at Posted at 2018-11-09

VBでSFTP接続しファイルアップロードする方法

VBでは標準の機能ではSFTP接続できないようです。(FTPSならできるようですが)
ライブラリを使用してSFTP接続し処理を行います。

今回使ったライブラリは以下です。
https://www.componentpro.com/products/sftp

Example

.vb
Imports System.IO
Imports ComponentPro.IO
Imports ComponentPro.Net

Module Module1

    Sub Main()

        ' Create a new class instance. 
        Dim client As New Sftp()

        ' Connect to the SFTP server.
        client.Connect("XXX.XXX.XXX.XXX", 22)

        ' Authenticate user with a private key.
        client.Authenticate("USER_NAME", "C:\private.key", "password")

        ' Do something here...
        Dim fi As New FileStream("C:\image.jpg", FileMode.Open)
        client.UploadFile(fi, "/img/image.jpg")

        'Disconnect
        fi.Close()
        client.Disconnect()

    End Sub

End Module
3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?