c# 键值数据保存XML文件
/// <summary> /// 键值数据保存XML文件 /// </summary> /// <param name="fileName">文件名</param> /// <param name="data">数据</param> public static bool SaveXmlFile(string filePath, string fileName, SerializableDictionary<string, string> data) { if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } using (FileStream fileStream = new FileStream(filePath + fileName, FileMode.Create)) { XmlSerializer xmlFormatter = new XmlSerializer(typeof(SerializableDictionary<string, string>)); xmlFormatter.Serialize(fileStream, data); } if (File.Exists(filePath + fileName)) { return true; } return false; }
从此山高路远,纵马扬鞭。愿往后旅途,三冬暖,春不寒,天黑有灯,下雨有伞。此生尽兴,不负勇往。