System.Net.FtpWebRequest.GetResponse C# (CSharp) Method

GetResponse() public method

public GetResponse ( ) : System.Net.WebResponse
return System.Net.WebResponse
        public override System.Net.WebResponse GetResponse() { throw null; }
    }

Same methods

FtpWebRequest::GetResponse ( ) : WebResponse

Usage Example

Beispiel #1
1
        /// <summary>
        /// 连接FTP的方法
        /// </summary>
        /// <param name="ftpuri">ftp服务器地址,端口</param>
        /// <param name="ftpUserID">用户名</param>
        /// <param name="ftpPassword">密码</param>
        public DownloadFtp(string ftpuri, string ftpUserID, string ftpPassword)
        {
            // 根据uri创建FtpWebRequest对象
              ft = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpuri));
              // ftp用户名和密码
              ft.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
              ft.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
             fr = (FtpWebResponse)ft.GetResponse();
              stream = fr.GetResponseStream();
              ////二进制文件读入
              //if (!fr.ContentType.ToLower().StartsWith("text/"))
              //{
              //    SaveBinaryFile(fr);
              //}
              ////文本文件
              //else
              //{
              string buffer = "", line;
              StreamReader reader = new StreamReader(stream);
              while ((line = reader.ReadLine()) != null)
              {
                  buffer += line + "\r\n";
              }

              //装入整个文件之后,接着就要把它保存为文本文件。
              SaveTextFile(buffer);
              //}
        }
All Usage Examples Of System.Net.FtpWebRequest::GetResponse