码迷,mamicode.com
首页 > Web开发 > 详细

用list获取已经上传到目录的文件内容进行分页显示

时间:2017-08-31 19:14:53      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:sub   job   direct   ring   文件名   int   length   name   query   

public List<Model> GetFileName(string filePath)
{
var queryParam = queryJson.ToJObject();
string[] filePaths = Directory.GetDirectories(filePath);//获取目录下的所有文件夹路径
string[] fileNames = null; //声明空数组

ArrayList array = new ArrayList();

List<FileWord> lst = new List<FileWord>();
for (int i = 0; i < filePaths.Length; i++)//循环获取文件名
{
fileNames = Directory.GetFiles(filePaths[i]);//把文件名放到数组中去
foreach (var item in fileNames)//把文件名添加到ArrayList
{
array.Add(item);
}
}
for (int i = 0; i < array.Count; i++)
{
Model fw = new Model();
//文件路径
string FilePath = array[i].ToString().Replace("\\", "/");//将\\转换成/
//文件夹名
string TemplateClass = FilePath.Substring(0, FilePath.LastIndexOf("/"));
string FName = FilePath.Substring(FilePath.LastIndexOf("/") + 1);
fw.FName =FName.Substring(0,FName.LastIndexOf(‘.‘)) ;
fw.TemplateClass = TemplateClass.Substring(TemplateClass.LastIndexOf("/") + 1);
lst.Add(fw);//将类添加到lst集合
}


lst = lst.Skip(页数 *行数 - 行数).Take(行数).ToList();//Linq分组
return lst;
}

用list获取已经上传到目录的文件内容进行分页显示

标签:sub   job   direct   ring   文件名   int   length   name   query   

原文地址:http://www.cnblogs.com/Effortslyl/p/7459531.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!