2

So I set up the FTP server properly in IIS 6.0. Initially I was not able to create or upload files to the FTP servers due to not having the Write permission. Then I gave all the permissions properly. After that I was able to create or upload files/directory using FileZilla(FTP client for Windows). But from my C# code I am still not able to upload a file into the ftp server using the same credentials that I have used in Filezilla.

The code I am using for uploading file to the FTP server:

        var request = (FtpWebRequest) WebRequest.Create(string.Format("{0}/{1}", _ftpServer, fileName));
        request.Method = WebRequestMethods.Ftp.UploadFile;
        request.KeepAlive = false;
        request.Credentials = new NetworkCredential(_userName, _password);
        //request.UsePassive = false;
        var ftpStream = request.GetRequestStream();

It is giving the 505 error at the last line in the given code.

So, why I am able to create and upload file/directory using the ftp client but not by my C# code?

What I am missing?

EDIT: From code I am able to create directory but not able to upload.

Bipul
  • 1,327
  • 4
  • 16
  • 33
  • 1
    Hi, did you found any solution? I am facing the same problem – OrElse Jan 25 '11 at 19:03
  • @Chocol8 I ended up using the FTPClient class. It's very good and easy to use. You can get the code here http://www.codeproject.com/KB/IP/ftplibrary.aspx . As you will get the code directly, you can change or create your own methods into the FTPClient itself. So, I will suggest go ahead with FTPClient. – Bipul Jan 27 '11 at 02:46
  • Perhaps you are running into this problem? http://stackoverflow.com/questions/4464271/c-sharp-ftp-550-error – Miroslav Bajtoš Feb 20 '12 at 15:42

0 Answers0