123456789101112131415161718192021 |
- using System.Text.Json;
- using Microsoft.Extensions.Configuration;
- using System.IO;
- namespace sera_slackbot.Library
- {
- public class JsonFileSaver
- {
- private string path;
- public JsonFileSaver(IConfiguration config)
- {
- path = config.GetSection("Persistence").GetValue<string>("Path");
- }
- public void Save(string filename, dynamic data)
- {
- var filePath = path + "/" + filename;
- File.WriteAllText(filePath, JsonSerializer.Serialize(data, new JsonSerializerOptions { WriteIndented = true }));
- }
- }
- }
|