//////////////////////获取服务器上的文件夹信息
string result = "";
string path = HttpContext.Current.Server.MapPath("~/UploadFiles");
DirectoryInfo rootDirectory = new DirectoryInfo(path);
//获取其所有子文件夹
DirectoryInfo[] directories = rootDirectory.GetDirectories();
foreach (DirectoryInfo temp in directories)
{
//文件夹名称
string FileName = temp.Name;
result += FileName + ",";
//文件夹路径
string Url = temp.FullName.Replace(path, "");
//最后更新时间
DateTime UpdateTime = temp.LastWriteTime;
}
//////////////////////获取服务器上的文件信息
FileInfo[] files = rootDirectory.GetFiles();
foreach (FileInfo temp in files)
{
//获取文件名
string FileName = temp.Name;
//获取文件路径
string Url = temp.FullName.Replace(path, "");
DateTime UpdateTime = temp.LastWriteTime;
//获取文件扩展名
string FileExtension = temp.Extension;
//获取当前文件的大小
string FileLength = ((int)temp.Length / 1024).ToString() + "KB";
}