public DataSerie3D Read_DS3(string fileName) { DataSerie3D ds3 = null; try { if (fileName == string.Empty) { return(null); } if (File.Exists(fileName)) { using (FileStream fs = File.Open(fileName, FileMode.Open)) { ds3 = new DataSerie3D(); BinaryReader bnryReader = new BinaryReader(fs); int dCount = 0; ds3.Name = bnryReader.ReadString(); ds3.Description = bnryReader.ReadString(); ds3.X_Title = bnryReader.ReadString(); ds3.Y_Title = bnryReader.ReadString(); ds3.Z_Title = bnryReader.ReadString(); dCount = bnryReader.ReadInt32(); if (dCount > 0) { string title; double x, y, z; for (int i = 0; i < dCount; i++) { title = bnryReader.ReadString(); x = bnryReader.ReadDouble(); y = bnryReader.ReadDouble(); z = bnryReader.ReadDouble(); ds3.Add(title, x, y, z); } } bnryReader.Close(); } } else { throw new FileNotFoundException("File not found", fileName); } } catch (Exception ex) { throw ex; } return(ds3); }
public DataSerie3D Read_DS3() { DataSerie3D ds3 = null; try { if (File.Exists(this.mFileName)) { ds3 = new DataSerie3D(); using (FileStream fs = File.Open(this.mFileName, FileMode.Open)) { using (StreamReader sReader = new StreamReader(fs)) { ds3.Name = sReader.ReadLine(); ds3.Description = sReader.ReadLine(); string title = sReader.ReadLine(); string[] titles = title.Split(';'); if (titles.Count() == 3) { ds3.Title = titles[0]; ds3.X_Title = titles[1]; ds3.Y_Title = titles[2]; ds3.Y_Title = titles[3]; } double xx, yy, zz; while (sReader.EndOfStream == false) { title = sReader.ReadLine(); titles = title.Split(';'); if (titles.Count() == 4) { xx = double.Parse(titles[1]); yy = double.Parse(titles[2]); zz = double.Parse(titles[3]); ds3.Add(titles[0], xx, yy, zz); } } } } } } catch (Exception ex) { throw ex; } return(ds3); }