CEWorkbench.Playback.SkeletonPlayer.Load C# (CSharp) Method

Load() public method

public Load ( string filePath ) : void
filePath string
return void
        public void Load(string filePath)
        {
            if (!File.Exists(filePath))
                throw new Exception(String.Format("File {0} does not exists", filePath));

            recordFile = new FileStream(filePath, FileMode.Open, FileAccess.Read);
            reader = new BinaryReader(recordFile);

            if (recordFile.Length == 0)
                throw new Exception(String.Format("File {0} is empty", filePath));

            int objectLenght = reader.ReadInt32();
            if (objectLenght <= 0)
                throw new Exception(String.Format("The file does not seem to have the right format - objectLenght: {0}", objectLenght));

            byte[] buffer = new byte[objectLenght];
            reader.Read(buffer, 0, objectLenght);
            MemoryStream stream = new MemoryStream(buffer);
            SkeletonCapture capture = (SkeletonCapture)formatter.Deserialize(stream);
            recordFile.Seek(0, SeekOrigin.Begin);
        }