CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2008
    Posts
    1

    Post The remote server returned an error: (530) Not logged in.

    Hi,

    I am trying to write a windows application in C# (Visual Studio 2008) that will pick up a file on an FPT with SSH server. I have connected to this server using WS FTP Pro and it worked fine. Here is the code I have written:

    FileStream outputStream = new FileStream(Utility.GetNewFileName(), FileMode.Create);
    FtpWebRequest reqFTP;

    reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ConfigurationManager.AppSettings["FTPServerName"] + ConfigurationManager.AppSettings["FTPFileName"]));

    reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
    reqFTP.UseBinary = true;
    reqFTP.Proxy = null;

    reqFTP.Credentials = new NetworkCredential(UserName, Password);
    FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
    Stream ftpStream = response.GetResponseStream();
    long cl = response.ContentLength;
    int bufferSize = 2048;
    int readCount;
    byte[] buffer = new byte[bufferSize];

    readCount = ftpStream.Read(buffer, 0, bufferSize);
    while (readCount > 0)
    {
    outputStream.Write(buffer, 0, readCount);
    readCount = ftpStream.Read(buffer, 0, bufferSize);
    }

    ftpStream.Close();
    outputStream.Close();
    response.Close();

    The line that is failing is: FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();

    The error returned is (530) Not Loggin in. I know those are the correct username and password because I can login with thos using the WS FTP Pro program and I can do it there.

    I am new to FTP so hopefully someone can help me.

    Thanks,
    Christel

  2. #2
    Join Date
    Mar 2008
    Location
    IRAN
    Posts
    811

    Re: The remote server returned an error: (530) Not logged in.

    i think the problem is here:
    reqFTP.Credentials = new NetworkCredential(UserName, Password);

    if the UserName you use is something like e.g. toraj58 and the domain of your site is something like mysite.com
    i guess you have not qualified username with @.

    then try this:

    reqFTP.Credentials = New NetworkCredential("toraj58@mysite.com", "yourpassword")
    Please rate my post if it was helpful for you.
    Java, C#, C++, PHP, ASP.NET
    SQL Server, MySQL
    DirectX
    MATH
    Touraj Ebrahimi
    [toraj_e] [at] [yahoo] [dot] [com]

  3. #3
    Join Date
    Nov 2010
    Posts
    1

    Thumbs up Re: The remote server returned an error: (530) Not logged in.

    Thanks man !!!!!! it resolved my problem. I was worrying what was going wrong but after reading this article i got it worked.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured