コード例 #1
0
        public static void Store(string fileName, JsonArrayCollection contents, bool prettyPrint)
        {
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            var filePath = Path.Combine(JsonFiler.path, fileName + extension);

            if (contents != null && contents.Count != 0)
            {
                var data = prettyPrint ? JsonPrettify(contents.ToJsonString()) : contents.ToJsonString();
                if (!data.EndsWith(Environment.NewLine, StringComparison.Ordinal))
                {
                    data += '\n';
                }
                File.WriteAllText(filePath, data);
            }
        }