예제 #1
0
        private void TraverseFileSystem(TreeNode <IFileSystemEntry> parent, FileSystemInfo entryInfo)
        {
            FolderFileEntry fileEntry = new FolderFileEntry(entryInfo.FullName);

            _registeredEntries.Add(fileEntry);
            TreeNode <IFileSystemEntry> node = new TreeNode <IFileSystemEntry>(fileEntry);

            parent.Add(node);

            if (entryInfo is DirectoryInfo directoryInfo)
            {
                foreach (var childEntry in directoryInfo.EnumerateFileSystemInfos())
                {
                    TraverseFileSystem(node, childEntry);
                }
            }
        }
예제 #2
0
        public IFileSystemEntry CreateEntry(string path)
        {
            string absolutePath = Path.Combine(_directoryInfo.FullName, path);

            using (Stream stream = File.Create(absolutePath))
            {
            }

            FolderFileEntry entry = new FolderFileEntry(absolutePath);

            string[] pathFragments = path.Split('\\');
            var      parent        =
                TreeNode <IFileSystemEntry> .SearchPath(_treeNode, pathFragments, pathFragments.Length - 1, f => f.Name);

            parent.Add(new TreeNode <IFileSystemEntry>(entry));

            return(entry);
        }