指数
[无私的分享:从入门到精通ASP.NET MVC ]从0开始,建立了一个框架,做一个项目目录索引
文件管理,这个比较鸡肋,但有一些方法你可以参考下
项目软件项目管理
我们运用的工具是:VS 2013 + SQL Server 2012 + iis7.5
希望我们有ASP.NET MVC的理论有一个初步的了解,我们不做过多的解释,有些不懂的地方也不要紧,将上线,更多用于长时间自然明白。敏捷开发流程
项目开始
居然叫它一点文件管理,这个功能可以是鸡肋,但研发项目管理
的一些方法,一个我们新的控制器uplOAdcontrollers
1 1,我们创建了下面的commanage地区一家看来,fileext留下来接收用户选择的文件型
1 & lt总结& gt 2 / / / / / /;;文件管理默认页3 / / / & lt;/摘要>;返回>;4 / / / <;<;/返回>;[ userauthorizeattribute(modulealias = 5,operaaction =“文件”、“视图”)公共ActionResult(家)6 ] 7 { 8 VAR fileext = request.querystrin G [“fileext”]?? “9 ViewData[“; “fileExt”] = fileExt; 10 return; 11 (View)}
1, 2 we create a file access method and then try to page through ajax data
1 < 2 summary> / / / / / /; through the path to obtain all documents / / / 3 < /summary> returns> 4 / / / < < /returns> 5 public ActionResult GetAllFileData (string) 6 {7 fileExt = Request.Form[“fileExt”]; 8 var jsonM = new (JsonHelper) {Status = “Y”, Msg = “success”}; 9 try 10 var 11 images = {ConfigurationManager.AppSettings[“Image].Trim (”).Split (New string[] StringSplitOptions.Re}, {“, ” MoveEmptyEntries (.Select) P => “.” + P).ToList (12); VAR videos = ConfigurationManager.AppSettings[“Video”].Trim (”,.Split (New string[]) {} “,” StringSplitOptions.RemoveEmptyEntries,.Select (P) => “.” + P).ToList (13); VAR musics = ConfigurationManager.AppSettings[“Music (“].Trim ‘,’.Split (New string[]) {} “,” StringSplitOptions.RemoveEmptyEntries,.Select (P) => “.” + P).ToList (14); VAR documents = ConfigurationManager.AppSettings[“Document”].Trim (”,.Split (New string[]) {} “,”.Select (P, StringSplitOptions.RemoveEmptyEntries) => P.ToList) + “.” (1516); switch (fileExt) 17 {18 case “images”: 1920 JsonM.Data = Common.Utils.DataTableToList< FileModel> (FileHelper.GetAllFileTable (Server.MapPath (ConfigurationManager.AppSettings[“uppath”])).OrderByDescending (P) => p.name (.Where) p=> images.Any (e=> e==p.ext)) (.ToList); 21 break; 22 case “videos”: 2324 jsonM.Data =常见工具。datatabletolist <;filemodel >;filehelper.getallfiletable((Server.MapPath(ConfigurationManager里[“uppath.orderbydescending(P)]))= & gt;器(P)。= & gt视频。任何(E;= & gt;E = p.ext)(。可以突破25));;26例音乐:jsonm。数据= 2728常见。工具。datatabletolist <;filemodel >;(filehelper.getallfiletable(server.mappath(ConfigurationManager里[“uppath”])))。OrderByDescending(P = & gt;p.name.where(P)= & gt;音乐。任何(E = & gt;E = p.ext)(29)。列出);断裂;30例“文件”:3132 jsonm。数据(filehelper.getallfiletable =常见。工具。datatabletolist <;filemodel >;Server.MapPath((ConfigurationManager里[“uppath”])))。OrderByDescending(P = & gt;p.name.where(P)= >;文件。任何(E = & gt;E = p.ext)(33)。列出);断裂;34例“他人”:3536 jsonm。数据=常见。工具。datatabletolist <;filemodel & gt((server.mappath;filehelper.getallfiletable(ConfigurationManager里[“uppath”])))。OrderByDescending(P = >;p.name.where(P)= & gt;包含图像!(p.ext)&;&;包含视频!(p.ext)&;&;包含音乐!(p.ext)&;&;包含文件!(p.ext)),ToList(37);破38默认值:39;jsonm。数据=常见。工具。datatabletolist <;filemodel >;(filehelper.getallfiletable(server.mappath(ConfigurationManager里[“uppath”]))。OrderByDescending(P)= & gt;器(。列出));40断;41 } 4243 } 44 { 46 45抓(例外)jsonm。状态=“错误”;4 7 jsonm。味精=“获取文件失败!”49 return 48;} Content (JsonConverter.Serialize (jsonM, true));} 50
1, 3 FileModel
1 model summary> / / / < / / / 3 / / / 2 file name < /summary> 4 public string name {get set;}; / / / 5 & lt; summary> / / / 7 / / / 6 file name < /summary> 8 public string fullname {get; set; < summary>} / / / 9; 10 / / / / / / 11 file path < /summary> 12; public string path {get; set; < summary>} / / / 13; 14 / / / 15 / / / < document format; /summary> 16; public string ext {get; set; < summary>} / / / 17 / / / 18; File size 19 /summary> 20 public; / / / < string size {get; set; < summary>} / / / 21; 22 / / / 23 / / / < file icon; /summary> 24 public string icon {get; set; < summary>} / / / 25; 26 / / / 27 / / / < folder is 28 public; /summary> bool isfolder {get; set; < summary>} / / / 29; 30 / / / / / / is picture 31 < /summary> 32; public bool isImage {get; set; < summary>} / / / 33; 34 / / / 35 / / / uplOAd time < /summary> 36; public DateTime set;} time {get;
1, 4  FileHelper; GetAllFileTable method we have obtained data into Dat file ATable returned
1 < summary> 2 / / / / / /;; access directory of all documents (including subdirectories) 3 / / / < /summary> 4; param name= / / / < Path > < /param> returns> 5 / / / < < /returns> 67 public static DataTable GetAllFileTable (string Path) {8 9 DataTable DT = new DataTable (10); dt.Columns.Add (“name”, typeof (string) 11 (dt.Columns.Add); “ext”, typeof (string) 12 (dt.Columns.Add); “size”, typeof (string) 13 (dt.Columns.Add); “icon”, typeof (string) 14 (dt.Columns.Add); “isfolder”, typeof (bool) 15 (dt.Columns.Add); “isImage”, typeof (bool) 16 (dt.Columns.Add); “Fullname”, typeof (string) 17 (dt.Columns.Add); “path”, typeof (string) 18 (dt.Columns.Add); “time”, typeof (DateTime) 1920); string[] folders = Directory.GetDirectories (Path, “*”, SearchOption.AllDirectories 2122); List< string> Listfloders = new (List< string> {Path}); 2324 if (folders! = null &;&;>;0(文件夹。计数),(瓦尔河)25 { 26文件夹在文件夹listfloders。加(夹)27 { 28 } 30 } 29);3132个(VAR在listfloders DirectoryInfo DirInfo = 33){ 34个DirectoryInfo(F)听;35网络;36文件名字符串,字符串。空,fileext =字符串。空,文件大小=字符串。空,fileicon =字符串。空,filefullname =字符串。空,文件路径=字符串。空37;布尔isfloder = false,形象=假;日期时间38 filemodify;39试为40(FileSystemInfo FSI在{ 41 dirinfo.getfiles(42)){ fi = 4344(FileInfo)流固耦合;45获得文件名46 / /文件名= fi.name.substring(0,fi.name.lastindexof(’ ‘));filefullname FI。名称= 47;48 / /获取文件的扩展名49 fileext = FI。Exten Sion.ToLower(50);//获取file size 51 FileSize = GetDiyFileSize (FI); / / get 52 LastModified 53 FileModify = fi.LastWriteTime; FileIcon = 55 / / 54 file icon GetFileIcon (FileExt); / / 56 is IsImage = IsImageFile (picture 57 (1 FileExt.Substring, FileExt.Length – 1)); / / 58 file the path of the 59 FilePath = urlconvertor (fi.FullName); DataRow Dr = dt.NewRow (6061; 62) dr[“name”] = 63 FileName; dr[“fullname”] = FileFullName 64; dr[“ext”] = 65 FileExt; dr[“size”] = 66 FileSize; dr[“time”] = 67 FileModify; dr[“icon”] = 68 FileIcon; dr[“isfolder”] = 69 IsFloder; dr[“isImage”] = 70 IsImage; dr[“path”] = FilePath; 71 dt.Rows.Add (DR); 72} 73} 74 {catch (Exception E) 75 throw 7677 e 78;} 79} 8081} return DT 82;
1, 5
disp在我用jquery.tmpl.js插件可以与流行的  AngularJS
JS文件列表;这包括加载的文件列表,删除文件,删除多个文件,显示文件的路径,复制文件,移动文件,压缩文件,解压缩文件等方法,我们会拿出1的方法
(功能){ $(2)(filesmanage.initfiles;3);无功filesmanage = 4 } { 5 initfiles:(功能){ $。后(6“/ COM /上传/ getallfiledata”(“{ fileext:#美元
文章从互联网整理而来,旨在传播scrum、软件项目管理、研发项目管理、敏捷开发管理工具的知识与应用,帮助软件开发企业真正了解研发项目管理的价值和意义,如果本文侵犯了您的权益或者您需要具体了解更多国内做研发项目管理系统的公司翼发云敏捷项目管理系统的相关信息,欢迎和我们联络:
【网址】www.effapp.com