-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
47 lines (41 loc) · 1.05 KB
/
Program.cs
File metadata and controls
47 lines (41 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
namespace AM.InMemoryFileSystemTree
{
class Program
{
static void Main()
{
string[] paths =
{
"dir1/subdir1/file1.txt",
"dir1/subdir1/file2.txt",
"dir2/subdir2/subsubdir2/file3.txt",
"file0.txt"
//"dir2/file2.txt"
};
var fsTree = new InMemoryFileSystemTree("root");
foreach (var path in paths)
{
fsTree.Add(path, 0, 0);
}
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"Directory structure:");
Console.ForegroundColor = ConsoleColor.Gray;
var json = fsTree.ToJson();
foreach (var node in json)
{
Console.WriteLine($"{{ \"path\": \"" + node.Path + "\", \"dirs\": \"" + node.DirectoryCount + "\", \"files\": \"" + node.FileCount + "\" },");
}
Console.WriteLine();
string p = "/dir1/subdir1/";
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"Files at Path: {p}");
Console.ForegroundColor = ConsoleColor.Gray;
var files = fsTree.GetFilesAtPath(p);
foreach(var file in files)
{
Console.WriteLine(file.Path);
}
}
}
}