Skip to content

Latest commit

 

History

History
57 lines (45 loc) · 2.36 KB

File metadata and controls

57 lines (45 loc) · 2.36 KB

ConsoleTree.FileSystem

version downloads

A tool to write the directory tree to the console standard output stream, with colors support and a lot of customization options.

Getting started

Use the following command to add the package to a .NET project:

dotnet add package ConsoleTree.FileSystem

More options are available on the package page of the NuGet Gallery website.

Usage

Instantiate a FileSystemNode specifying the root directory and, optionally, if files must be included, a function to filter them and a sort order. To write the directory tree to the console standard output stream, call the ConsoleTree.Tree.Write method specifying the FileSystemNode instance as parameter.

using ConsoleTree;
using ConsoleTree.FileSystem;

Tree.Write(new FileSystemNode("docs", new SearchSettings
{
    IncludeFiles = true,
    Predicate = fsi => !fsi.Attributes.HasFlag(FileAttributes.Hidden),
    Comparer = new DirectoriesFirstComparer()
}), new DisplaySettings {IndentSize = 2});

// Output:
//
// docs\
// ├──ConsoleTree.FileSystem\
// │  ├──DirectoriesFirstComparer\
// │  │  ├──Compare.md
// │  │  └──DirectoriesFirstComparer.md
// │  ├──FileSystemNode\
// │  │  ├──FileSystemInfo.md
// │  │  ├──FileSystemNode.md
// │  │  ├──GetNodes.md
// │  │  └──ToString.md
// │  ├──SearchSettings\
// │  │  ├──Comparer.md
// │  │  ├──IncludeFiles.md
// │  │  ├──Predicate.md
// │  │  └──SearchSettings.md
// │  ├──DirectoriesFirstComparer.md
// │  ├──FileSystemNode.md
// │  └──SearchSettings.md
// └──ConsoleTree.FileSystem.md

Resources

See the API reference and the ConsoleTree.FileSystem.Demo application for further informations. See also the ConsoleTree API reference to learn how to customize indentation, maximum depth, type of connectors and colors.