public static calib GetCalib(int no) { calib c = new calib(); if (!File.Exists(@"SD\settings\calib_" + no.ToString() + ".dat")) { using (FileStream fs = new FileStream(@"SD\settings\calib_" + no.ToString() + ".dat", FileMode.Create, FileAccess.Write)) { StreamWriter writer = new StreamWriter(fs); writer.Write(Join('/', defaultCalib)); writer.Flush(); writer.Close(); } VolumeInfo.GetVolumes()[0].FlushAll(); // ulozim vse na SD !!! nutne !!! } using (FileStream fs = new FileStream(@"SD\settings\calib_" + no.ToString() + ".dat", FileMode.Open, FileAccess.Read)) { StreamReader reader = new StreamReader(fs); string result = reader.ReadLine(); c.GetParams(result); reader.Close(); } return c; }
public static string[] SetParams(this string[] outref, calib obj) { outref[(int)ckey.coef] = obj.coef.ToString(); outref[(int)ckey.small] = obj.small.ToString(); outref[(int)ckey.medium] = obj.medium.ToString(); outref[(int)ckey.large] = obj.large.ToString(); return outref; }
public static void SaveCalib(int no, calib calib) { using (FileStream fs = new FileStream(@"SD\settings\calib_" + no.ToString() + ".dat", FileMode.Open, FileAccess.Write)) // { StreamWriter writer = new StreamWriter(fs); writer.Write(Join('/', outref.SetParams(calib))); writer.Flush(); writer.Close(); } VolumeInfo.GetVolumes()[0].FlushAll(); }