locked
FTP error 550

    Question

  • HI!
         I am using vs.net2005 and vb.net to make  a windows application.I have written the following code to download files from ftp server. But everytime i execute the code the error 550(file not found, access denied) error appears.plz help me.

    Private Sub Download(ByVal filePath As String, ByVal fileName As String)

    Dim ftp As System.Net.IPHostEntry '''me

    Dim ftp2 As System.Net.IPAddress

    Dim reqFTP As FtpWebRequest

    Dim ftpuserid As String 'ftp user id

    Dim ftpserverip As String 'ftp server ip

    Dim ftppassword As String 'ftp password

    ftpserverip = "aaa.bbb.ccc.eee"

     

    ftpuserid = "xyz"

     

    ftppassword = "xyzzz"

     

    Try

    Dim outputStream As New FileStream(filePath + "\" + fileName, FileMode.Create) ''path of the file where the d/w file will be created

     

    reqFTP = DirectCast(FtpWebRequest.Create(New Uri("ftp://" + ftpserverip + "/" + fileName)), FtpWebRequest)

    reqFTP.Method = WebRequestMethods.Ftp.DownloadFile

    reqFTP.UseBinary = True

    reqFTP.Credentials = New NetworkCredential(ftpuserid, ftppassword)

    '''''''''''''''Getting FTP Response

     

    Dim response As FtpWebResponse = DirectCast(reqFTP.GetResponse(), FtpWebResponse)

    Dim ftpStream As Stream = response.GetResponseStream()

    Dim cl As Long = response.ContentLength

    Dim bufferSize As Integer = 8196

    Dim readCount As Integer

     

    Dim buffer As Byte() = New Byte(bufferSize - 1) {}

    readCount = ftpStream.Read(buffer, 0, bufferSize)

    While readCount > 0

    outputStream.Write(buffer, 0, readCount)

    readCount = ftpStream.Read(buffer, 0, bufferSize)

    End While

     

    ftpStream.Close()

    outputStream.Close()

    response.Close()

    Catch ex As Exception

    MessageBox.Show(ex.Message)

    End Try

    End Sub
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Please Do help me........


    Best Regards
     Omar_aa

    Tuesday, June 03, 2008 4:20 AM

Answers

  • Hi Omar_aa,

    I don't know your scenario, but I use My.Computer.Network.DownloadFile method to download the files without authentication (anonymous access) or with authentication without problem. It shouldn't  be the coding problem and should be the configuration issue. It looks like that the user hasn't permission to download file based on the error message.

    Best regards,
    Riquel
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by OM_12 Tuesday, June 10, 2008 4:15 AM
    Tuesday, June 10, 2008 2:23 AM
    Moderator

All replies

  • Hi Omar_aa,

    First try using My.Computer.Network.DownloadFile("ftp://localhost/1.html", "d:/1.html", "username", "pwd") in this scenario. Second the 550 error is a message from the server stating that the account you have currently logged in as does not have permission to perform the action you are attempting. You may be trying to download the file which doesn't exist or you haven't the permission to download this file. Could you download this file in IE?

    Best regards,
    Riquel

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Thursday, June 05, 2008 7:19 AM
    Moderator
  • thnx for ur reply...but the problem is i m able to download files from the free anonymous (nousername, no password)ftp sites but whennever i try to download a file from ma specific server with specific username and password....i get this error.....
    plz reply as soon as possible..........
    Best Regards
    Awais Omar

    Thursday, June 05, 2008 8:12 AM
  • Hi Omar_aa,

    I don't know your scenario, but I use My.Computer.Network.DownloadFile method to download the files without authentication (anonymous access) or with authentication without problem. It shouldn't  be the coding problem and should be the configuration issue. It looks like that the user hasn't permission to download file based on the error message.

    Best regards,
    Riquel
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by OM_12 Tuesday, June 10, 2008 4:15 AM
    Tuesday, June 10, 2008 2:23 AM
    Moderator
  • Thnx for ur kind help...it was a configuration issue.......Can u please guide me that how can i obtain directory Listing from ftp server in vb.net.thanks in advance
    Best Regards
    Omar_aa 
    Tuesday, June 10, 2008 4:14 AM
  • Have a look at the FtpWebRequest class. You need to set FtpWebRequest.Method property. See WebRequestMethods.Ftp Members for your reference now. 
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Friday, June 20, 2008 1:15 AM
    Moderator