ASP 获取FTP服务器上的文件列表和最后修改时间
FTP是我自己,里面基本都是图片,我想把FTP上的文件的列表显示在网页上,并且可以筛选出最新修改时间的图片!!求各位大神帮帮忙,给个例子或者给点思路 --------------------编程问答-------------------- public static List<string> GetFile(string RequedstPath)
{
List<string> strs = new List<string>();
try
{
string uri = path + RequedstPath; //目标路径 path为服务器地址
FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri));
// ftp用户名和密码
reqFTP.Credentials = new NetworkCredential(username, password);
reqFTP.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
WebResponse response = reqFTP.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());//中文文件名
string line = reader.ReadLine();
while (line != null)
{
if (!line.Contains("<DIR>"))
{
string msg = line.Substring(39).Trim();
strs.Add(msg);
Console.WriteLine(msg);
}
line = reader.ReadLine();
}
reader.Close();
response.Close();
return strs;
}
catch (Exception ex)
{
Console.WriteLine("获取文件出错:" + ex.Message);
}
return strs;
}
补充:.NET技术 , ASP.NET