public void Write(DeviceDataView data, string nameFile) { BinaryFormatter binFormatter = new BinaryFormatter(); using (FileStream deviceData = new FileStream(nameFile, FileMode.Create)) { binFormatter.Serialize(deviceData, data); } }
//public List<IEmployeeble> Read(string nameFile) //{ // List<IEmployeeble> employee = null; // BinaryFormatter binFormater = new BinaryFormatter(); // using (FileStream employeeData = new FileStream(nameFile, FileMode.OpenOrCreate)) // { // if (employeeData.Length != 0) // { // employee = (List<IEmployeeble>)binFormater.Deserialize(employeeData); // } // } // return employee; //} public DeviceDataView ReadDevicesData(string nameFile) { DeviceDataView data = null; BinaryFormatter binFormatter = new BinaryFormatter(); using (FileStream devicesData = new FileStream(nameFile, FileMode.OpenOrCreate)) if (devicesData.Length != 0) { data = (DeviceDataView)binFormatter.Deserialize(devicesData); } else { } return(data); }