Upload with FTP vb.net

Discussion in 'ASP.NET 2.0' started by Bruce, Mar 22, 2007.

  1. Bruce

    Bruce DiscountASP.NET Staff

  2. Hi. I use this subroutine to upload some .pdf (30Kb each), but after upload a few (150-200) i got an error. Is this connected with our hosting? How can i solve the problem? Thanks.

    Private Sub Upload(ByVal source As String, ByVal target As String, ByVal credential As NetworkCredential)
    Dim request As FtpWebRequest = _
    DirectCast(WebRequest.Create(target), FtpWebRequest)
    request.Method = WebRequestMethods.Ftp.UploadFile
    request.Credentials = credential
    Dim reader As New FileStream(source, FileMode.Open)
    Dim buffer(Convert.ToInt32(reader.Length - 1)) As Byte
    reader.Read(buffer, 0, buffer.Length)
    reader.Close()
    request.ContentLength = buffer.Length
    Dim stream As Stream = request.GetRequestStream
    stream.Write(buffer, 0, buffer.Length)
    stream.Close()
    Dim response As FtpWebResponse = DirectCast(request.GetResponse, FtpWebResponse)
    'MessageBox.Show(response.StatusDescription, "File Uploaded")
    response.Close()
    End Sub
     
  3. Could be several reasons,space,firewall etc. Please post the exact error message.

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     

Share This Page