Beispiel #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);
        }
Beispiel #2
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;
        }