Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cvietor/pathtotreeconverter
C# PathToTree Converter
https://github.com/cvietor/pathtotreeconverter
converter tree-structure
Last synced: 2 days ago
JSON representation
C# PathToTree Converter
- Host: GitHub
- URL: https://github.com/cvietor/pathtotreeconverter
- Owner: cvietor
- License: mit
- Created: 2017-06-15T19:40:10.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-29T10:32:41.000Z (over 7 years ago)
- Last Synced: 2025-01-02T13:05:51.268Z (5 days ago)
- Topics: converter, tree-structure
- Language: C#
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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 methodvar result = converter.Convert(paths);
// now do something funky with your list of tree nodes
```