static void Test6() { string dirpath = FileHatchery.Engine.Components.Config.Util.getExecutablePath(); Console.WriteLine(dirpath); string filepath = dirpath + "\\test.dat"; Console.WriteLine(filepath); XmlSerializer seri = new XmlSerializer(typeof(FileHatchery.Engine.Components.Config.SerializableDictionary <string, string>)); FileHatchery.Engine.Components.Config.SerializableDictionary <string, string> vv; FileStream str = File.Open(filepath, FileMode.OpenOrCreate); try { object des = seri.Deserialize(str); vv = des as FileHatchery.Engine.Components.Config.SerializableDictionary <string, string>; } catch (Exception) { vv = new FileHatchery.Engine.Components.Config.SerializableDictionary <string, string>(); } vv["asdf"] = "news"; str.Seek(0, SeekOrigin.Begin); seri.Serialize(str, vv); }
static void Test6() { string dirpath = FileHatchery.Engine.Components.Config.Util.getExecutablePath(); Console.WriteLine(dirpath); string filepath = dirpath + "\\test.dat"; Console.WriteLine(filepath); XmlSerializer seri = new XmlSerializer(typeof(FileHatchery.Engine.Components.Config.SerializableDictionary<string, string>)); FileHatchery.Engine.Components.Config.SerializableDictionary<string, string> vv; FileStream str = File.Open(filepath, FileMode.OpenOrCreate); try { object des = seri.Deserialize(str); vv = des as FileHatchery.Engine.Components.Config.SerializableDictionary<string, string>; } catch (Exception) { vv = new FileHatchery.Engine.Components.Config.SerializableDictionary<string, string>(); } vv["asdf"] = "news"; str.Seek(0, SeekOrigin.Begin); seri.Serialize(str, vv); }