tags:

views:

48

answers:

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.

A: 

Maybe someone else will know exactly. If not I would use wireshark to compare the FileZilla requests with the ones from your application and see what is different.

Martin Smith
A: 

This could help you out pointer

this-Me
Thanks for the reply, but I don't think it is the problem of large file. The file I am trying to send is a one page txt file.
Bipul