public bool Write(DataSerie5D ds5) { bool result = false; try { using (FileStream fs = File.Open(this.mFileName, FileMode.OpenOrCreate)) { using (StreamWriter sw = new StreamWriter(fs)) { //sw.WriteLine(ds5.Name); //sw.WriteLine(ds5.Description); //sw.WriteLine(string.Format("{0}; {1}; {2}", ds5.Title, ds5, ds5.Y_Title)); if (object.Equals(ds5.Data, null)) { return(false); } foreach (DataItem5D itm in ds5.Data) { sw.WriteLine(string.Format("{0}; {1}; {2}; {3}; {4}", itm.A_Value, itm.B_Value, itm.C_Value, itm.D_Value, itm.E_Value)); } sw.Flush(); result = true; } } } catch (Exception ex) { throw ex; } return(result); }
public List <DataSerie5D> Read_DS5List() { List <DataSerie5D> d5Series = new List <DataSerie5D>(); try { if (FileName == string.Empty) { return(null); } if (File.Exists(this.FileName)) { using (FileStream fs = File.Open(this.FileName, FileMode.Open)) { using (BinaryReader bnryReader = new BinaryReader(fs)) { int dCount = 0; dCount = bnryReader.ReadInt32(); if (dCount > 0) { DataSerie5D ds5; int itmCount = 0; for (int i = 0; i < dCount; i++) { ds5 = new DataSerie5D(); ds5.Name = bnryReader.ReadString(); ds5.Description = bnryReader.ReadString(); ds5.Title = bnryReader.ReadString(); ds5.A_Title = bnryReader.ReadString(); ds5.B_Title = bnryReader.ReadString(); ds5.C_Title = bnryReader.ReadString(); ds5.D_Title = bnryReader.ReadString(); ds5.E_Title = bnryReader.ReadString(); itmCount = bnryReader.ReadInt32(); if (itmCount > 0) { string title; double aa, bb, cc, dd, ee; for (int j = 0; j < itmCount; j++) { title = bnryReader.ReadString(); aa = bnryReader.ReadDouble(); bb = bnryReader.ReadDouble(); cc = bnryReader.ReadDouble(); dd = bnryReader.ReadDouble(); ee = bnryReader.ReadDouble(); ds5.Add(title, aa, bb, cc, dd, ee); } } d5Series.Add(ds5); } } } } } else { throw new FileNotFoundException("File not found", this.FileName); } } catch (Exception ex) { throw ex; } return(d5Series); }