带有FTPwebrequest的FTPS错误550 [英] FTPS error 550 with FTPwebrequest

查看:65
本文介绍了带有FTPwebrequest的FTPS错误550的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

请帮助我解决以下错误

远程服务器返回错误550文件不可用的错误,例如找不到文件无法访问."

我正在尝试通过FTPS上传文件.
FTPS服务器不需要具有要上传的文件.
每次我都会上传新文件.
我们需要上传数百个文件dail.

但是我在uploadRequest.GetRequestStream()上遇到了以上错误.

提前谢谢..

我的代码如下:

Hi All,

Kindly help me with the below error

"the remote server returned an error 550 file unavailable e.g. file not found no access ."

I am trying to upload file through FTPS.
It is not required for the FTPS server to have the file which I am going to upload.
Everytime I will upload new new files.
100s of files we will need to upload dail.

however I am getting the above error at uploadRequest.GetRequestStream().

Thanks in advance..

My code is below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
namespace ConsoleApplication1
{
    class Class1
    {
        public static void Main(string[] args)
        {
            Stream requestStream = null;
            FileStream fileStream = null;
            FtpWebResponse uploadResponse = null;
            try
            {
                Uri uploadUrl = new Uri("ftp://blaabll.blabala.com/folder/");
                string fileName = "c:\\sangeetha.xlsx";
                FtpWebRequest uploadRequest =
                 (FtpWebRequest)WebRequest.Create(uploadUrl + @"/" + fileName);
                uploadRequest.Method = WebRequestMethods.Ftp.UploadFile              //Since the FTP you are downloading to is secure, send
                //in user name and password to be able upload the file
                ICredentials credentials = new NetworkCredential(user, password);
                uploadRequest.Credentials = credentials;
                //UploadFile is not supported through an Http proxy
                //so we disable the proxy for this request.
                uploadRequest.Proxy = null;
                //uploadRequest.UsePassive = false; <--found from another forum and did not make a difference
           <b>      requestStream = uploadRequest.GetRequestStream()</b> 
                fileStream = File.Open(fileName, FileMode.Open);
                byte[] buffer = new byte[1024];
                int bytesRead;
                while (true)
                {
                    bytesRead = fileStream.Read(buffer, 0, buffer.Length);
                    if (bytesRead == 0)
                        break;
                    requestStream.Write(buffer, 0, bytesRead);
                }
                //The request stream must be closed before getting
                //the response.
                requestStream.Close();
                uploadResponse =
                  (FtpWebResponse)uploadRequest.GetResponse();
            }
            catch (UriFormatException ex)
            {
             //   ErrorsHappened.Items.Add("Error: " + ex.Message);
            }
            catch (IOException ex)
            {
              // ErrorsHappened.Items.Add("Error: " + ex.Message);
            }
            catch (WebException ex)
            {
                //ErrorsHappened.Items.Add("Error: " + ex.Message);
            }
            finally
            {
                if (uploadResponse != null)
                    uploadResponse.Close();
                if (fileStream != null)
                    fileStream.Close();
                if (requestStream != null)
                    requestStream.Close();
            }
        }
    }
}

推荐答案

错误550是权限失败( [ ^ ],谢谢Google).因此,可能是您没有为要使用的用户正确设置要尝试写入的文件夹的权限.确保该用户拥有该文件夹并且其访问标志至少为5xx,或者该用户与文件夹所有者位于同一组中并且其访问标志至少为x5x.使用chmod更改访问标志. (您也可以使用全局写许可权xx5来执行此操作,但除非是任何人都可以在此处写的匿名匿名删除,否则不建议这样做.)
Error 550 is a permission failure (source[^], thanks Google). So, chances are you did not set up the permissions on the folder you are trying to write to correctly for the user you''re using. Make sure that either that user owns the folder and it has access flags at least 5xx, or the user is in the same group as the folder owner and it has access flags at least x5x. Use chmod to change the access flags. (You could also do it with global write permission, xx5, but unless it''s an anonymous drop that is not recommended as anyone could write there.)


这篇关于带有FTPwebrequest的FTPS错误550的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆