FtpWebRequest returns error 550 File unavailable

前端 未结 15 2163
醉梦人生
醉梦人生 2020-11-30 09:41

I have created a small windows forms application to upload the file to one of our client\'s ftp site. But the problem that I\'m having is that when I run this application on

相关标签:
15条回答
  • 2020-11-30 10:18

    I too had this problem recently. What I found is that when I use ftpUploadFile the routine is trying to put the file in the root ftp folder. Normal command line ftp worked fine. However issuing a pwd command from the command line ftp revealed that this particular server was setting a different current directory upon login. Altering my ftpUploadFile to include this folder resolved the issue.

    0 讨论(0)
  • 2020-11-30 10:21

    I found the solution. The problem is the Current Working Directory of the ftp user. If you type a url like ftp:///path/test.txt it is used as a relative path ro the working directory. For example CWD is /test then the used path is /test/path/test.txt. If you want to use an absolute path, you have to type the url like ftp:////path/test.txt. Then the file is uploaded in the folder /path/test.txt, without exception.

    0 讨论(0)
  • 2020-11-30 10:21

    In my case, there was a root folder referenced in my ftp address that was missing. After to create the folder the problem was solved.

    ftp://xxx.xxx.xx.xx:21//rootfolder/

    0 讨论(0)
  • 2020-11-30 10:22

    When i had the same issue i tried everything above and after a day later i realize that the path which i created for uri having a white space in between "/" and the folder name

    string uri="192.168.1.101/ Sync/Image.jpg";
    

    the above string should be

    string uri="192.168.1.101/Sync/Image.jpg";
    

    this small mistake also throws the same error and it's a valid error because this is not valid path for our file if it contains any white spaces between "/" and folder/file name

    0 讨论(0)
  • 2020-11-30 10:23

    I was also having the same issue. After monitoring the traffic with WireShark I understood the problem

    I had set up a new FTP site on my local IIS FTP server named 'testftp' The 'testftp' site was pointing to a folder named d:\ftp on my computer's hard disk I was getting the '550' error whenever i tried to execute the line in bold in C# code below ftpHostURL="ftp://127.0.0.1/testftp/test.htm"; request = (FtpWebRequest)WebRequest.Create(ftpHostURL); request.Proxy = new WebProxy(); //-----Proxy bypassing(The requested FTP command is not supported when using HTTP proxy)

                request.Method = WebRequestMethods.Ftp.UploadFile;
                request.Credentials = new NetworkCredential(ftpUserName, ftpPassword);
               // uploadFilePath = "d://test//tt.txt";
                using (var requestStream = request.GetRequestStream())
                {
                    using (var input = File.OpenRead(uploadFilePath))
                    {
                        input.CopyTo(requestStream);
                    }
                }
    

    I tried a lot of solutions mentioned in various websites but nothing helped. Then I came across a site that suggested to use WireShark to monitor the traffic.

    On monitoring the traffic using the RawCap Utility I saw that the application was trying to execute the code below

    STOR testftp/test.htm

    Then I understood the problem. IIS was expecting a folder named 'testftp' to be there under the ftp root folder which was not there. I was considering 'testftp' as the name of the virtual folder created in IIS where as IIS understood it as a folder under the FTP root

    Creating a folder named 'testftp' under the FTP root folder solved my issue.

    Hope this is helpful to someone

    Regards Mathew

    0 讨论(0)
  • 2020-11-30 10:24

    I met the same problem, and this is what I did:

    1. Check the OS has the right to write. Find the ftp folder =>right click=>properties=>security, then you must know what you should do
    2. Check the ftp server open the write right to the user you logged. Open IIS=>click the ftp site=>ftp Authorization Rules=>add allow rules=>choose a user or group to set the rights
    3. Check the the dir on the ftp server, do the same thing on item 2.

    I can use four pictures to show the rights to be set: enter image description here

    enter image description here enter image description here enter image description here

    0 讨论(0)
提交回复
热议问题