FTP System.Net.WebException: 远程服务器返回错误: (550) 文件不可用(例如,未找到文件,无法访问文件)。

原因没有创建文件夹的路径

  try
            {
                Connect(path);
                reqFTP.Method = WRMethods;
                response =(FtpWebResponse) reqFTP.GetResponse();
                if(response==null)
                {
                    Log.Error("[FTPTool][GetFileList][GetResponse] is NULL");
                    return null;
                }
                else
                {
                    Log.Info("[response data is: ]"+response.StatusCode.ToString() + " " + response.StatusDescription.ToString());
                }

                Log.Info("[FTPTool][GetResponse] status: {0}", response.StatusDescription);
                reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8);//中文文件名
                string line = reader.ReadLine();
                while (line != null)
                {
                    Log.Info("[Line ReaderLine ]"+line);
                    result.Append(line);
                    result.Append("\n");
                    line = reader.ReadLine();
                   
                }
                // to remove the trailing ' ' 
                result.Remove(result.ToString().LastIndexOf('\n'), 1);

                return result.ToString().Split('\n');
            }
            catch (Exception ex)
            {
                Log.Error("[FtpTools][GetFileList]" + ex.ToString());

                Log.Info("[Ex Message]"+ex.Message);
                Log.Info("[Ex InnerException]" + ex.InnerException);
                Log.Info("[Ex HResult]" + ex.HResult.ToString());
                Log.Info("[Ex Message]" + ex.Source);
                Log.Info("[Contenttype]" + response.ContentType);
                Log.Info("[ExitMessage]" + response.ExitMessage);

                downloadFiles = null;
                return downloadFiles;
            }

如果FTP没有该路径C#会报错,报Exception

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Farmwang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值