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获取已经上传到目录的文件内容进行分页显示
原文地址:http://www.cnblogs.com/Effortslyl/p/7459531.html