예제 #1
0
        private IEnumerable<Media> GetImageList(IEnumerable<string> files)
        {
            var list = new List<Media>();

            foreach (var file in files)
            {
                if (!IsImage(file)) continue;

                var name = Path.GetFileName(file);
                var url = Path.Combine(_path, (name ?? ""));

                url = url.Replace(@"\", @"/");

                var item = new Media
                {
                    ContentType = "image",
                    IsDirectory = false,
                    Name = name,
                    Size = 50,
                    Url = url
                };

                list.Add(item);
            }

            return list;
        }
예제 #2
0
        private IEnumerable<Media> GetDirectoryList(IEnumerable<string> folders)
        {
            var list = new List<Media>();

            foreach (var folder in folders)
            {
                var name = Path.GetFileName(folder);
                var url = Path.Combine(_path, (name ?? ""));

                var media = new Media
                {
                    ContentType = "folder",
                    IsDirectory = true,
                    Name = name,
                    Size = null,
                    Url = url
                };

                list.Add(media);
            }

            return list;
        }