C # FTP Error 550

I am trying to programmatically upload a file in C # via FTP, here is the corresponding code (obviously with fake crednials and URIs):

try
{
    var request = FtpWebRequest.Create("ftp://ftp.mydomain.com/folder/file.zip");
    request.Credentials = new NetworkCredential("username", "password");

    using (var response = request.GetResponse())
    {
         ...
    }
}
catch (WebException we)
{
    ...
}

The exception is thrown at request.GetResponse(), and the error code is 550. The problem is not with the credentials or with the URIs, since they work fine in IE and the files load successfully there. What am I missing? Is there any other authority object I should use? Is there a property of an object requestthat I do not set? Any help would be appreciated.

+3
source share
6 answers

FTP URL. , , : ftp.mydomain.com /folder, URL- ftp://ftp.mydomain.com/file.zip. IE8 , / , FtpRequest , IE8, #.

+6

( : ):

var request = FtpWebRequest.Create("ftp://ftp.mydomain.com//folder/file.zip");

.

+4

, , .Method - ,

        request = (FtpWebRequest)FtpWebRequest.Create(address);
        request.Credentials = new NetworkCredential("username", "password");
        request.UsePassive = true;
        request.UseBinary = true;
        request.Proxy = null;

        request.Method = WebRequestMethods.Ftp.DownloadFile;
        FtpWebResponse dataResponce = (FtpWebResponse)request.GetResponse();
+1

Method.

 request.Method = WebRequestMethods.Ftp.DownloadFile;
+1

, , - URI , .ToLower() URI

0

Source: https://habr.com/ru/post/1780741/


All Articles