private void LoadCameraConfigurations(uint taskID) { var directory = TasksModel.GenerateSavedTaskPath(taskID); // Create directory if it doesn't exist: if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } // Read file: var file = directory + "Cameras.data"; if (File.Exists(file)) { MemoryStream data; using (var stream = File.OpenRead(file)) { using (var binaryStream = new BinaryReader(stream)) { var bytes = binaryStream.ReadBytes((int)stream.Length); data = new MemoryStream(bytes); } } // Deserialize object: CameraManager.Deserialize(new BinaryReader(data)); } }
private void SaveCameraConfigurations(uint taskID) { var directory = TasksModel.GenerateSavedTaskPath(taskID); // Create directory if it doesn't exist: if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } // Serialize cameras: var data = new MemoryStream(); CameraManager.Serialize(new BinaryWriter(data)); // Write to file: var file = directory + "Cameras.data"; using (var stream = File.OpenWrite(file)) { using (var binaryStream = new BinaryWriter(stream)) { binaryStream.Write(data.ToArray(), 0, (int)data.Length); } } }