-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScanResultFileService.cs
More file actions
33 lines (28 loc) · 935 Bytes
/
Copy pathScanResultFileService.cs
File metadata and controls
33 lines (28 loc) · 935 Bytes
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
using System;
using System.IO;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace c2flux
{
public static class ScanResultFileService
{
public static void Save(string filePath, FileSystemEntry rootEntry)
{
JsonSerializerOptions options = new JsonSerializerOptions
{
WriteIndented = false,
ReferenceHandler = ReferenceHandler.Preserve
};
File.WriteAllText(filePath, JsonSerializer.Serialize(rootEntry, options));
}
public static FileSystemEntry Load(string filePath)
{
string json = File.ReadAllText(filePath);
JsonSerializerOptions options = new JsonSerializerOptions
{
ReferenceHandler = ReferenceHandler.Preserve
};
return JsonSerializer.Deserialize<FileSystemEntry>(json, options);
}
}
}