服务器上有一个带有换行符的文本文件:
1
2
3
我尝试通过FTP获取他并显示在表单上:
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://x.x.x.x/test.txt");
request.UseBinary = false;
request.Method = WebRequestMethods.Ftp.DownloadFile;
request.KeepAlive = false;
request.Credentials = new NetworkCredential("login", "password");
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream);
richTextBox1.Text = reader.ReadToEnd();
response.Close();
但是尽管出现“ UseBinary = false”,我还是得到了:
123
如果我使用ascii模式通过cmd获取此文件,则该文件看起来不错(包含“ \ n”)。怎么了?