コード例 #1
0
        /// <summary>
        /// 日志文件列表
        /// </summary>
        /// <returns></returns>
        public ActionResult FileList()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("[");
            DirectoryInfo dir = new DirectoryInfo(Server.MapPath("/log"));

            FileInfo[] files = dir.GetFiles();
            FileDateSorter.QuickSort(files, 0, files.Length - 1);//按时间排序
            foreach (FileInfo fsi in files)
            {
                sb.Append("{");
                sb.Append("\"id\":\"" + fsi.Name + "\",");
                sb.Append("\"text\":\"" + fsi.Name + "\",");
                sb.Append("\"value\":\"" + fsi.Name + "\",");
                sb.Append("\"img\":\"/Content/Images/Icon16/page_white_error.png\",");
                sb.Append("\"isexpand\":true,");
                sb.Append("\"hasChildren\":false");
                sb.Append("},");
            }
            sb = sb.Remove(sb.Length - 1, 1);
            sb.Append("]");
            return(Content(sb.ToString()));
        }
コード例 #2
0
        /// <summary>
        /// PDF目录列表
        /// </summary>
        /// <returns></returns>
        public ActionResult TreeJson()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("[");
            DirectoryInfo dir = new DirectoryInfo(Server.MapPath("~/Resource/PDF"));

            FileInfo[] files = dir.GetFiles("*.pdf", SearchOption.AllDirectories);
            FileDateSorter.QuickSort(files, 0, files.Length - 1);//按时间排序
            foreach (FileInfo fsi in files)
            {
                sb.Append("{");
                sb.Append("\"id\":\"" + fsi.Name + "\",");
                sb.Append("\"text\":\"" + fsi.Name + "\",");
                sb.Append("\"value\":\"" + fsi.Name + "\",");
                sb.Append("\"img\":\"../../Content/Images/Icon16/file_extension_pdf.png\",");
                sb.Append("\"isexpand\":true,");
                sb.Append("\"hasChildren\":false");
                sb.Append("},");
            }
            sb = sb.Remove(sb.Length - 1, 1);
            sb.Append("]");
            return(Content(sb.ToString()));
        }