Exemplo n.º 1
0
        public CFtp2(string Url, FtpServerType ServerType, bool UsePassive)
        {
            Uri u = new Uri(Url);

            CFtpInfo finfo = new CFtpInfo();

            finfo.ServerType = ServerType;
            finfo.UsePassive = UsePassive;

            finfo.Host = u.Host;
            finfo.Port = u.Port;

            if (!string.IsNullOrEmpty(u.UserInfo))
            {
                string[] aUserPwd = u.UserInfo.Split(':');
                finfo.UserId = aUserPwd[0];

                if (aUserPwd.Length > 1)
                {
                    finfo.Password = aUserPwd[1];
                }
            }

            _Info = finfo;
        }
Exemplo n.º 2
0
 /// <summary>
 /// 判断ftp服务器类型,
 /// 类型为Unknown时才执行
 /// </summary>
 /// <param name="lines">文件信息列表</param>
 private FtpServerType GetServerType(FtpServerType fst, string[] lines)
 {
     if (fst == FtpServerType.Unknown)
     {
         foreach (string l in lines)
         {
             if (l.Length > 10 &&
                 System.Text.RegularExpressions.Regex.IsMatch(l.Substring(0, 10), "(-|d)(-|r)(-|w)(-|x)(-|r)(-|w)(-|x)(-|r)(-|w)(-|x)"))
             {
                 return(fst = FtpServerType.Unix);
             }
             else if (l.Length > 8 &&
                      System.Text.RegularExpressions.Regex.IsMatch(l.Substring(0, 8), "[0-9][0-9]-[0-9][0-9]-[0-9][0-9]"))
             {
                 return(fst = FtpServerType.Windows);
             }
         }
     }
     return(fst);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the FTP platform.
        /// </summary>
        /// <param name="serverType">Type of the server.</param>
        /// <param name="system">The full platform.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentOutOfRangeException">serverType;null</exception>
        private static FtpPlatform GetFtpPlatform(FtpServerType serverType, string system)
        {
            switch (serverType)
            {
            case FtpServerType.Unknown:
                return(new FtpPlatform());

            case FtpServerType.Unix:
                if (system.IndexOf("FileZilla", StringComparison.InvariantCultureIgnoreCase) >= 0)
                {
                    return(new WindowsFileZillaFtpPlatform());
                }
                return(new UnixFtpPlatform());

            case FtpServerType.Windows:
                return(new WindowsFtpPlatform());

            default:
                throw new ArgumentOutOfRangeException("serverType", serverType, null);
            }
        }