分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > IT知识

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

发布时间:2023-09-06 01:07责任编辑:顾先生关键词:暂无标签

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

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved