public static void SaveFrom(ISaveData instance) { if (instance != null) { if (!Directory.Exists(_folder)) { Directory.CreateDirectory(_folder); } var fileName = AddOrChangeFileName(instance.SaveTag()); File.WriteAllBytes(GetPath(fileName), AESUtils.AESEncrypt(instance.SaveAsJson())); } }
// 存储索引到文件 static void SaveFileNames() { var indexFilePath = GetPath(_saveFile); JsonData data = new JsonData(); foreach (var pair in _fileNames) { data[pair.Key] = pair.Value; } var json = data.ToJson(); File.WriteAllBytes(indexFilePath, AESUtils.AESEncrypt(json)); }