Torna al Thread

Public Function uploadFileUsingFTP(ByVal CompleteFTPPath As String, ByVal CompleteLocalPath As String, Optional ByVal UName As String = "", Optional ByVal PWD As String = "") As String uploadFileUsingFTP = Nothing Dim resultMsg As String = "Upload complete" Try Dim reqObj As FtpWebRequest = WebRequest.Create(CompleteFTPPath) reqObj.Method = WebRequestMethods.Ftp.UploadFile reqObj.Credentials = New NetworkCredential(UName, PWD) Dim streamObj As System.IO.FileStream = System.IO.File.OpenRead(CompleteLocalPath) Dim buffer(streamObj.Length) As Byte streamObj.Read(buffer, 0, buffer.Length) streamObj.Close() streamObj = Nothing reqObj.GetRequestStream().Write(buffer, 0, buffer.Length) reqObj = Nothing Return resultMsg Catch ex As Exception resultMsg = ex.Message End Try End Function
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5