zoukankan      html  css  js  c++  java
  • C# FTP 命令无法获取ServerU目录列表问题 转载的啊

      使用C# 的Ftp功能时,发现了一个很奇怪的现象,获取目录列表的命令,在SeverU上面直接返回错误,而在windows自带的FTP上则正常,经过反复试验,终于发现,原来是ServerU默认情况下,不允许使用NLST命令获取目录列表,只要在 “设置”-〉“高级”中,选中“NLST命令也列出目录”即可。{
     3                 //检查一下日期目录是否存在
     4                 FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(directory);
     5 
     6                 reqFTP.UseBinary = true;
     7 
     8                 reqFTP.Credentials = new NetworkCredential(GlobalManager.FTPUserID, GlobalManager.FTPPassword);
     9 
    10                 reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
    11 
    12                 Stream stream = reqFTP.GetResponse().GetResponseStream();
    13 
    14                 using (StreamReader sr = new StreamReader(stream))
    15                 {
    16                     string line = sr.ReadLine();
    17 
    18                     while (!string.IsNullOrEmpty(line))
    19                     {
    20                         if (line == foldName)
    21                         {
    22                             exist = true;
    23                             break;
    24                         }
    25 
    26                         line = sr.ReadLine();
    27                     }
    28                 }
    29             }
    30             catch (Exception e)
    31             {
    32                 exist = false;
    33             }

  • 相关阅读:
    博客园页面设置(转载)
    正则表达式30分钟入门教程 (转载)
    如何写出优雅的代码
    centos7 nginx+php5.6+mysql安装与配置
    git 进阶
    js 异步解决方案
    行动派
    unicode 与 utf-8
    bower command not found--windows
    click事件细节
  • 原文地址:https://www.cnblogs.com/wcLT/p/2977178.html
Copyright © 2011-2022 走看看