FileStream fs = new FileStream("Answears.dat", FileMode.Create);
Dictionary<string, List<string>> chats = new Dictionary<string, List<string>>();
BinaryFormatter formatter = new BinaryFormatter();
public void Start()
{
chats = (Dictionary<string, List<String>>) formatter.Deserialize(fs); //here is a error
fs.Close();
}
您现在还有其他任何选项以将字典(以及以后再加载)保存在文件中。^^
感谢您的帮助
paul:)
我将使用json.net,独立于汇编版本更改并导致可读文本...
File.WriteAllText(filename, JsonConvert.SerializeObject(yourDict));
以后,您可以将其加载为
var yourDict = JsonConvert.DeserializeObject<Dictionary<string,List<string>>>(File.ReadAllText(filename));