1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
Public Sub ftpConnect()
Try
Dim myadress As String = "ftp://" & "192.168.42.20 & "/home/linux.bin"
Dim serverUri As Uri = New Uri(myadress)
If serverUri.Scheme <> Uri.UriSchemeFtp Then
Return
End If
Dim myRequest As FtpWebRequest = DirectCast(WebRequest.Create(serverUri), FtpWebRequest)
myRequest.Credentials = New NetworkCredential(iniLogin, iniPass)
myRequest.Method = WebRequestMethods.Ftp.UploadFile
myRequest.UsePassive = True
myRequest.UseBinary = True
myRequest.KeepAlive = False
Dim File() As Byte = System.IO.File.ReadAllBytes(LinuxFile) 'LinuxFile = D:\linux.bin
Dim UpFile As System.IO.Stream = myRequest.GetRequestStream()
UpFile.Write(File, 0, File.Length)
UpFile.Close()
UpFile.Dispose()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub |
Partager