Algorithmix.Shred.Load C# (CSharp) Method

Load() public static method

Deserialize binary shred on disk into memory
public static Load ( string filepath ) : Shred
filepath string filepath of the deserialized shred
return Shred
        public static Shred Load(string filepath)
        {
            if (!File.Exists(filepath))
            {
                throw new FileNotFoundException();
            }
            Stream stream = File.Open(filepath, FileMode.Open);
            BinaryFormatter binaryFormatter = new BinaryFormatter();
            Shred objectToDeserialize = (Shred) binaryFormatter.Deserialize(stream);
            stream.Flush();
            stream.Close();
            Logger.Info("Deserializing shred id={0} from filename={1}", objectToDeserialize.Id, filepath);
            return objectToDeserialize;
        }