Imports System.Net.Mail
Imports System.Net
Imports System.IO
Public Sub EnviaFtp(ByVal Arquivo As String, ByVal SiteFTp As String, ByVal Usuario As String, ByVal Senha As String)
Try
Dim clsRequest As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create(SiteFTp & "/" & System.IO.Path.GetFileName(Arquivo)), System.Net.FtpWebRequest)
clsRequest.Credentials = New System.Net.NetworkCredential(Usuario, Senha)
clsRequest.Method = System.Net.WebRequestMethods.Ftp.DownloadFile
' Lê o arquivo local
Dim bFile() As Byte = System.IO.File.ReadAllBytes(Arquivo)
' Escreve no destino
Dim clsStream As System.IO.Stream = clsRequest.GetRequestStream()
clsStream.Write(bFile, 0, bFile.Length)
clsStream.Close()
clsStream.Dispose()
Catch ex As Exception
'messagebox.show("Ocorreu um erro" & ex.message, "Erro")
End Try
End Sub
Nenhum comentário:
Postar um comentário