Exemplo n.º 1
0
        public ThemeModel GetFilesList(string path)
        {
            path = path.Replace("//", "/");
            var model = new ThemeModel();
            if (!Directory.Exists(Server.MapPath(path)))
                return model;

            var dic = new DirectoryInfo(Server.MapPath(path));
            foreach (var d in dic.GetFileSystemInfos())
            {
                if (d is DirectoryInfo)
                {
                    var fold = new FoldInfo
                    {
                        FoldName = d.Name,
                        FoldPath = path,
                        FileSystemInfosLength = ((DirectoryInfo)d).GetFileSystemInfos().Length,
                        UpdateTime = d.LastWriteTime
                    };
                    model.FoldList.Add(fold);
                }
                else
                {
                    var file = new FileInfo
                    {
                        FileName = d.Name,
                        FileLength = FileHelper.ConvertUnit(((System.IO.FileInfo)d).Length),
                        Extension = d.Extension,
                        FileUrl = path + "/" + d.Name,
                        FilePath = d.FullName,
                        UpdateTime = d.LastWriteTime
                    };
                    model.FileList.Add(file);
                }
            }
            return model;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 主题编辑
        /// </summary>
        /// <param name="themename"></param>
        /// <returns></returns>
        public ActionResult ThemeEdit(string themename)
        {
            var model = new ThemeModel();
            if (!string.IsNullOrEmpty(themename))
            {
                var path = "/themes/"+themename;
                if (!string.IsNullOrEmpty(urlpath))
                {
                    path = urlpath;
                }
                model = GetFilesList(path);
                if (!string.IsNullOrEmpty(urlpath))
                {
                    model.PathUrl = GetPathUrl();
                }

            }
            ViewBag.UrlPath = System.IO.Path.GetFileName(Request.Url.AbsolutePath);
            return View(model);
        }