Skip to content

cvietor/PathToTreeConverter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Jul 17, 2017
67decec · Jul 17, 2017

History

13 Commits
Jul 17, 2017
Jun 15, 2017
Jun 15, 2017
Jun 28, 2017
Jun 29, 2017

Repository files navigation

What is this?

A simple C# class that converts a list of string paths into a tree model.

How does that look?

Given an input like:

"//subFolder1",
"//subFolder1//subsubfolder1a",
"//subFolder1//subsubfolder1a//sub-sub-sub",
"//subFolder2",
"//subFolder2//subsubfolder1b"

turns into:

 + subFolder1
     + subsubfolder1a
         + sub-sub-sub
 + subFolder2
     + subsubfolder1b

How does that work?

Easy...

var paths = new[]
{
    "//subFolder1",
    "//subFolder1//subsubfolder1a",
    "//subFolder1//subsubfolder1a//sub-sub-sub",
    "//subFolder2",
    "//subFolder2//subsubfolder1b"
};

var converter = new PathsToTreeConverter();
converter.SetDelimiterSymbol("//"); // "/" is default, otherwise use the SetDelimiterSymbol method

var result = converter.Convert(paths);

// now do something funky with your list of tree nodes

About

C# PathToTree Converter

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages