public void DeserializePostalCodes() { try { if (File.Exists(PostalAdressfileName) == false) { return; } using (Stream stream = File.Open(PostalAdressfileName, FileMode.Open)) { PostalAdressLog log = PostalAdressLog.Create; BinaryFormatter bin = new BinaryFormatter(); var profiles = (Dictionary <string, PostalAdress>)bin.Deserialize(stream); foreach (var x in profiles) { log.adressList.Add(x.Key, x.Value); } } } catch (IOException ex) { throw new Exception(ex.Message); } }
public void PrintAllPostalCodes() { int count = 0; richTextBox1.Text += "------------------------\n\n"; PostalAdressLog log = PostalAdressLog.Create; foreach (KeyValuePair <string, PostalAdress> x in log.adressList) { richTextBox1.Text += ++count + "\t" + x.Value.PCD + "\t" + x.Key.ToString() + "\n"; richTextBox1.Update(); } }
public void SerializePostalCodes() { try { using (Stream stream = File.Open(PostalAdressfileName, FileMode.Create)) { PostalAdressLog log = PostalAdressLog.Create; BinaryFormatter bin = new BinaryFormatter(); bin.Serialize(stream, log.adressList); } } catch (IOException ex) { throw new Exception(ex.Message); } }
public void PrintAllValues() { PostalAdressLog log = PostalAdressLog.Create; if (ds.Tables[0] != null) { foreach (DataRow r in dt.Rows) { if (r != null && string.IsNullOrWhiteSpace(r[0].ToString()) == false) { string po = r[0].ToString(); if (log.adressList.ContainsKey(po)) { log.Add(new PostalAdress() { PCD = po }); } } } } }