Thanks,
代码如下:
using System.Net;
using System.IO;
System.Net.FtpWebRequest ftp = GetRequest(GetDirectory(directory));
ftp.Method = System.Net.WebRequestMethods.Ftp.ListDirectory;
string result = "";
using (FtpWebResponse response = (FtpWebResponse)ftp.GetResponse())
{
long size = response.ContentLength;
using (Stream datastream = response.GetResponseStream())
{
using (StreamReader sr = new StreamReader(datastream))
{
result = sr.ReadToEnd();
sr.Close();
}
datastream.Close();
}
}
response.Close();
上面代码功能,获取FTP服务器目录列表。
但,解析后的字符是乱码。
因为连接的是FTP服务器,假如并不知道服务器使用的编码是何种格式,如何才能正确解析呢?
求教
BR
Healthy