Пример #1
0
        private static void DirectorySearch(string folderPath, JsTreeNodeModel root, IFileRest fileRest)
        {
            root.Children     = new List <JsTreeNodeModel>();
            root.State.Opened = true;

            foreach (string fileName in Directory.GetFiles(folderPath))
            {
                if (AllowedExtensions != null && AllowedExtensions.Any(ext => fileName.EndsWith(ext)))
                {
                    BaseFile file = fileRest.Get(fileName);

                    FileInfo fileInfo = new FileInfo(fileName);
                    root.Children.Add(new JsTreeNodeModel
                    {
                        Text = fileInfo.Name,
                        Type = file == null ? "file_new" : "file_added",
                        Attr = new JsTreeAttr {
                            DataFilename = fileInfo.FullName
                        },
                        State = new JsTreeNodeState()
                    });
                }
            }

            foreach (string directoryName in Directory.GetDirectories(folderPath))
            {
                DirectoryInfo directoryInfo = new DirectoryInfo(directoryName);

                JsTreeNodeModel node = new JsTreeNodeModel
                {
                    Text  = directoryInfo.Name,
                    State = new JsTreeNodeState()
                };

                DirectorySearch(directoryName, node, fileRest);

                root.Children.Add(node);
            }
        }
Пример #2
0
        private static void DirectorySearch(string folderPath, JsTreeNodeModel root, IFileRest fileRest)
        {
            root.Children = new List<JsTreeNodeModel>();
            root.State.Opened = true;

            foreach (string fileName in Directory.GetFiles(folderPath))
            {
                if (AllowedExtensions != null && AllowedExtensions.Any(ext => fileName.EndsWith(ext)))
                {
                    BaseFile file = fileRest.Get(fileName);

                    FileInfo fileInfo = new FileInfo(fileName);
                    root.Children.Add(new JsTreeNodeModel
                    {
                        Text = fileInfo.Name,
                        Type = file == null ? "file_new" : "file_added",
                        Attr = new JsTreeAttr { DataFilename = fileInfo.FullName },
                        State = new JsTreeNodeState()
                    });
                }
            }

            foreach (string directoryName in Directory.GetDirectories(folderPath))
            {
                DirectoryInfo directoryInfo = new DirectoryInfo(directoryName);

                JsTreeNodeModel node = new JsTreeNodeModel
                {
                    Text = directoryInfo.Name,
                    State = new JsTreeNodeState()
                };

                DirectorySearch(directoryName, node, fileRest);

                root.Children.Add(node);
            }
        }
Пример #3
0
 private BaseFile Get(string fileName)
 {
     return(_fileRest.Get(fileName));
 }