Exemplo n.º 1
0
        public static FileManagerResource Get(string path)
        {
            var directory = new DirectoryInfo(path);

            var resource = new FileManagerResource
            {
                Path = directory.FullName,
                Text = directory.Name,
                IsDirectory = true
            };

            foreach (var child in directory.GetFiles())
            {
                resource.AddChild(new FileManagerResource
                {
                    Path = child.FullName,
                    Text = child.Name,
                    IsDirectory = false,
                    Icon = "file text outline icon"
                });
            }

            foreach (var child in directory.GetDirectories())
            {
                resource.AddChild(new FileManagerResource
                {
                    Path = child.FullName,
                    Text = child.Name,
                    IsDirectory = true,
                    Icon = "folder open outline icon"
                });
            }

            return resource;
        }
Exemplo n.º 2
0
        public static FileManagerResource Get(string path)
        {
            var directory = new DirectoryInfo(path);

            var resource = new FileManagerResource
            {
                Path        = directory.FullName,
                Text        = directory.Name,
                IsDirectory = true
            };

            foreach (var child in directory.GetFiles())
            {
                resource.AddChild(new FileManagerResource
                {
                    Path        = child.FullName,
                    Text        = child.Name,
                    IsDirectory = false,
                    Icon        = "file text outline icon"
                });
            }

            foreach (var child in directory.GetDirectories())
            {
                resource.AddChild(new FileManagerResource
                {
                    Path        = child.FullName,
                    Text        = child.Name,
                    IsDirectory = true,
                    Icon        = "folder open outline icon"
                });
            }

            return(resource);
        }
Exemplo n.º 3
0
        public void AddChild(FileManagerResource resource)
        {
            if (resource.IsDirectory)
            {
                resource = Get(resource.Path);
            }

            this.Children.Add(resource);
        }
Exemplo n.º 4
0
        public void AddChild(FileManagerResource resource)
        {
            if (resource.IsDirectory)
            {
                resource = Get(resource.Path);
            }

            this.Children.Add(resource);
        }
Exemplo n.º 5
0
        public static FileManagerResource NormalizePath(string root, FileManagerResource resource)
        {
            resource.Path = resource.Path.Replace(root, "").Replace(@"\", @"/");

            foreach (var child in resource.Children)
            {
                child.Path = child.Path.Replace(root, "").Replace(@"\", @"/");
                if (child.IsDirectory)
                {
                    NormalizePath(root, child);
                }
            }

            return(resource);
        }
Exemplo n.º 6
0
        public static FileManagerResource NormalizePath(string root, FileManagerResource resource)
        {
            resource.Path = resource.Path.Replace(root, "").Replace(@"\", @"/");

            foreach (var child in resource.Children)
            {
                child.Path = child.Path.Replace(root, "").Replace(@"\", @"/");
                if (child.IsDirectory)
                {
                    NormalizePath(root, child);
                }
            }

            return resource;
        }
Exemplo n.º 7
0
        public static FileManagerResource Get(string path, string extensions = "")
        {
            var directory = new DirectoryInfo(path);

            var resource = new FileManagerResource
            {
                Path        = directory.FullName,
                Text        = directory.Name,
                IsDirectory = true
            };

            var files = string.IsNullOrWhiteSpace(extensions) ? directory.GetFiles() : directory.GetFiles(extensions);

            foreach (var child in files)
            {
                resource.AddChild(new FileManagerResource
                {
                    Path        = child.FullName,
                    Text        = child.Name,
                    IsDirectory = false,
                    Icon        = "file text outline icon"
                });
            }

            foreach (var child in directory.GetDirectories())
            {
                resource.AddChild(new FileManagerResource
                {
                    Path        = child.FullName,
                    Text        = child.Name,
                    IsDirectory = true,
                    Icon        = "folder open outline icon"
                });
            }

            return(resource);
        }