private int LoadMetaFile(Message meta) { if (!File.Exists(meta.Filename + ".meta")) { byte[] bs = new byte[256 + 8]; Array.Copy(meta.Hash, 0, bs, 0, 256); Array.Copy(Utils.GetBytes((long)1), 0, bs, 256, 8); File.WriteAllBytes(meta.Filename + ".meta", bs); return(1); } using FileStream fs = new FileStream(meta.Filename + ".meta", FileMode.Open); byte[] hash = new byte[256]; byte[] id = new byte[8]; fs.Read(hash, 0, 256); if (hash.SequenceEqual(meta.Hash)) { fs.Read(id, 0, 8); return((int)Utils.BtoLong(id)); } else { throw new ChecksumMismatchException("Two files with same name have differed hash, please check your file or rename it."); } }