Created
November 27, 2017 04:22
-
-
Save voquanghoa/c37f3d9df60f83ace2d551f81017af56 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void SaveJson<T>(List<T> data, string directory) | |
{ | |
if (!Directory.Exists(directory)) | |
{ | |
Directory.CreateDirectory(directory); | |
} | |
var fileName = $"{typeof(T).Name}s.json"; | |
var filePath = Path.Combine(directory, fileName); | |
var json = JsonConvert.SerializeObject(data); | |
File.WriteAllText(filePath, json); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment