Esempio n. 1
0
        public FileTree GetSubTree(DirectoryInfo directory)
        {
            FileTree tree = SubFileTrees.FirstOrDefault(p => p.Directory?.FullName == directory.FullName);

            if (tree == null)
            {
                FileTree child = new FileTree(directory);
                SubFileTrees.Add(child);
                return(child);
            }
            else
            {
                return(tree);
            }
        }
Esempio n. 2
0
        private void InsertToFileTree(FileInfo file)
        {
            Stack <DirectoryInfo> directories = new Stack <DirectoryInfo>();
            DirectoryInfo         directory   = new DirectoryInfo(file.FullName);

            while ((directory = directory.Parent).FullName != task.TargetBackupDirectory)
            {
                directories.Push(directory);
            }

            FileTree currentTree = tree;

            while (directories.Count > 0)
            {
                directory   = directories.Pop();
                currentTree = currentTree.GetSubTree(directory);
            }
            currentTree.SubFileTrees.Add(new FileTree(file));
        }
Esempio n. 3
0
        public FileTree GetFileTree()
        {
            SearchFiles();
            tree = new FileTree(new DirectoryInfo(task.TargetBackupDirectory));

            //foreach (var path in filePaths)
            //{
            //    if (realFileInfos.ContainsKey(path))
            //    {
            //        InsertToFileTree(realFileInfos[path]);
            //    }
            //    else
            //    {
            //        InsertToFileTree(notExistFileInfo[path]);
            //    }
            //}

            foreach (var file in realFileInfos)
            {
                InsertToFileTree(file.Value);
            }
            return(tree.SubFileTrees[0]);
        }