You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.2 KiB
41 lines
1.2 KiB
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Text;
|
|
|
|
namespace GummingCommon
|
|
{
|
|
public class PatternSetting
|
|
{
|
|
public static void Save(string filename, object obj)
|
|
{
|
|
if (!Directory.Exists(FilesDirectory.PatternImagePath))
|
|
{
|
|
Directory.CreateDirectory(FilesDirectory.PatternImagePath);
|
|
}
|
|
string exportFileName = string.Format("{0}{1}.json", FilesDirectory.PatternImagePath, filename);
|
|
if (File.Exists(exportFileName))
|
|
{
|
|
File.Delete(exportFileName);
|
|
}
|
|
File.WriteAllText(exportFileName, JsonConvert.SerializeObject(obj));
|
|
}
|
|
|
|
public static string GetString(string filename)
|
|
{
|
|
if (!Directory.Exists(FilesDirectory.PatternImagePath))
|
|
{
|
|
Directory.CreateDirectory(FilesDirectory.PatternImagePath);
|
|
}
|
|
string jsonFileName = string.Format("{0}{1}.json", FilesDirectory.PatternImagePath, filename);
|
|
if (File.Exists(jsonFileName))
|
|
{
|
|
return File.ReadAllText(jsonFileName);
|
|
}
|
|
return string.Empty;
|
|
}
|
|
|
|
}
|
|
}
|