示例#1
0
        private FtpCommandResult GetResponse()
        {
            List <FtpCommandResultLine> l = new List <FtpCommandResultLine>();
            String lineText = "";
            FtpCommandResultLine CurrentLine = null;

            Byte[]       bb          = this.GetResponseBytes(new FtpDataReceiveContext(this.ResponseEncoding));
            StringReader sr          = new StringReader(this.ResponseEncoding.GetString(bb));
            Boolean      isFirstLine = true;

            while (true)
            {
                lineText = sr.ReadLine();
                if (isFirstLine == true)
                {
                    CurrentLine = new FtpCommandResultLine(lineText);
                }
                else
                {
                    CurrentLine = new FtpCommandResultLine(CurrentLine.StatusCode, lineText);
                }
                isFirstLine = false;
                l.Add(CurrentLine);
                //次の行があるかチェック
                if (CurrentLine.LastLine == true)
                {
                    break;
                }
            }
            this.Commnicating = false;
            return(new FtpCommandResult(l.ToArray()));
        }
示例#2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="lines"></param>
        public FtpCommandResult(FtpCommandResultLine[] lines)
        {
            StringBuilder sb = new StringBuilder();
            if (lines.Length == 0)
            { throw new ArgumentException("line must not be zero length."); }

            this._StatusCode = lines[0].StatusCode;
            for (int i = 0; i < lines.Length; i++)
            {
                sb.Append(lines[i].Text);
                if (i < lines.Length - 1)
                {
                    sb.AppendLine();
                }
            }
            this.Text = sb.ToString();
        }