如何从WebRequestMethods.Ftp.ListDirectoryDetails中提取文件名,文件大小,日期
注意: - 我完成了ListView .. 我的编码
private void btnListFiles_Click(object sender, EventArgs e)
{
string[] filenames = GetFilesDetailList();
dataGridView1.Rows.Clear();
foreach (string filename in filenames)
{
dataGridView1.Rows.Add(filename)
}
}
private string[] GetFilesDetailList()
{
ftp.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
ftp.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
WebResponse response = ftp.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string line = reader.ReadLine();
while (line != null)
{
result.Append(line);
result.Append("\n");
line = reader.ReadLine();
}
result.Remove(result.ToString().LastIndexOf("\n"), 1);
reader.Close();
response.Close();
return result.ToString().Split('\n');
//MessageBox.Show(result.ToString().Split('\n'));
}