private async void pregledBin() { openFileDialog1.Filter = "DAT files (*.dat)|*.dat"; openFileDialog1.FilterIndex = 1; openFileDialog1.RestoreDirectory = true; if (openFileDialog1.ShowDialog() == DialogResult.OK && openFileDialog1.FileName.EndsWith(".dat")) { ; } { using (FileStream fs = new FileStream(openFileDialog1.FileName, FileMode.Open)) { BinaryReader xr = new BinaryReader(fs); BinaryFormatter xs = new BinaryFormatter(); List <Uposleni> l = new List <Uposleni>(await Task.Run(() => xs.Deserialize(fs) as List <Uposleni>)); if (l != null) { DataGridUposleni dgu = new DataGridUposleni(l); dgu.ShowDialog(); } fs.Close(); } } }
private async void pregledXML() { openFileDialog1.Filter = "XML files (*.xml)|*.xml"; openFileDialog1.FilterIndex = 1; openFileDialog1.RestoreDirectory = true; if (openFileDialog1.ShowDialog() == DialogResult.OK && openFileDialog1.FileName.EndsWith(".xml")) { ; } { using (FileStream fs = new FileStream(openFileDialog1.FileName, FileMode.Open)) { XmlReader xr = XmlReader.Create(fs); XmlSerializer xs = new XmlSerializer(typeof(List <Uposleni>)); List <Uposleni> l = new List <Uposleni>(await Task.Run(() => xs.Deserialize(xr)) as List <Uposleni>); if (l != null) { DataGridUposleni dgu = new DataGridUposleni(l); dgu.ShowDialog(); } fs.Close(); } } }