This repository has been archived on 2025-11-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
AUTS_OLD/AUTS_UpdateService/FtpService.vb
2024-03-11 16:34:21 +08:00

51 lines
1.6 KiB
VB.net
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Imports FluentFTP
Public Class FtpService
Private _ftpUser As String
Private _ftpPwd As String
Private _ftpPort As Integer
Private _ftpHost As String
Sub New(host As String, port As Integer, user As String, pwd As String)
_ftpHost = host
_ftpPort = port
_ftpUser = user
_ftpPwd = pwd
End Sub
Private Sub OnValidateCertificate(control As FtpClient, e As FtpSslValidationEventArgs)
e.Accept = True
End Sub
''' <summary>
''' 文件上传
''' 将本地指定路径压缩包上传到FTP服务器上manager文件夹下
''' </summary>
Public Sub FtpUpload(remotePath As String, loadPath As String)
Using ftpClient As FtpClient = New FtpClient(_ftpHost, _ftpPort, _ftpUser, _ftpPwd)
AddHandler ftpClient.ValidateCertificate, AddressOf OnValidateCertificate
ftpClient.EncryptionMode = FtpEncryptionMode.Auto
ftpClient.Connect()
ftpClient.UploadFile(loadPath, remotePath)
ftpClient.Disconnect()
End Using
End Sub
''' <summary>
''' 文件下载
''' 从FTP下载压缩包到本地指定路径
''' </summary>
Public Sub FtpDownload(remotePath As String, loadPath As String)
Using ftpClient As FtpClient = New FtpClient(_ftpHost, _ftpPort, _ftpUser, _ftpPwd)
AddHandler ftpClient.ValidateCertificate, AddressOf OnValidateCertificate
ftpClient.EncryptionMode = FtpEncryptionMode.Auto
ftpClient.Connect()
ftpClient.DownloadFile(loadPath, remotePath)
ftpClient.Disconnect()
End Using
End Sub
End Class