private void Form1_Load(object sender, EventArgs e) { ass = Assembly.GetExecutingAssembly(); string[] res = ass.GetManifestResourceNames(); try { string name = "bjArkiv.xml.gz"; Stream rs = ass.GetManifestResourceStream(name); using (Stream gzip = new GZipStream(rs, CompressionMode.Decompress, true)) { using (MemoryStream menfile = new MemoryStream()) { for (int b = gzip.ReadByte(); b != -1; b = gzip.ReadByte()) { menfile.WriteByte((byte)b); } db = xmldocs.Load(menfile); xmldocsBindingSource.DataSource = db; } } } catch (Exception ex) { MessageBox.Show(this, ex.Message, ass.GetName().Name, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static xmldocs Load(MemoryStream ms) { XmlSerializer xs = new XmlSerializer(typeof(xmldocs)); try { try { ms.Position = 0; xmldocs Db = (xmldocs)xs.Deserialize(ms); Db.path = "ms"; return(Db); } catch { } } catch { } return(null); }
public static xmldocs Load(string path) { XmlSerializer xs = new XmlSerializer(typeof(xmldocs)); try { using (FileStream fs = new FileStream(path, FileMode.Open)) { try { fs.Position = 0; xmldocs Db = (xmldocs)xs.Deserialize(fs); Db.path = path; return(Db); } catch { } } } catch { } return(null); }