使用FtpWebRequest输出日志
FtpWebRequest
.
[R] USER xxx [R] 331 Please specify the password. [R] PASS (hidden) [R] 230 Login successful. [R] SYST [R] 215 UNIX Type: L8 [R] FEAT [R] 211-Features: [R] EPRT [R] EPSV [R] MDTM [R] PASV [R] REST STREAM [R] SIZE [R] TVFS [R] 211 End [R] PWD [R] 257 "/" [R] CWD / [R] 250 Directory successfully changed. [R] PWD [R] 257 "/" [R] TYPE A [R] 200 Switching to ASCII mode. [R] PASV [R] 227 Entering Passive Mode (10,232,201,81,141,175) [R] Opening data connection IP: 10.232.201.81 PORT: 36271 [R] LIST -al [R] 150 Here comes the directory listing. [R] 226 Directory send OK.
// Get the object used to communicate with the server.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(string.Format("ftp://{0}", addrEndPoint));
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
request.Credentials = new NetworkCredential(_currentConnection.Username, _currentConnection.Password);
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader readStream = new StreamReader(responseStream, System.Text.Encoding.UTF8);
if (readStream != null)
{
Console.WriteLine(readStream.ReadToEnd());
}