public static byte[] ReadBytes(string filePath, int offset, int length) { using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { Sanity.Requires(fs.Length >= offset + length, "File length error."); fs.Seek(offset, SeekOrigin.Begin); using (BinaryReader br = new BinaryReader(fs)) { return(br.ReadBytes(length)); } } }
public static void WriteBytes(string filePath, byte[] bytes, int offset) { using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Write)) { Sanity.Requires(fs.Length > offset + bytes.Length, "File length error."); fs.Seek(offset, SeekOrigin.Begin); using (BinaryWriter br = new BinaryWriter(fs)) { br.Write(bytes); } } }
private void ParseSchema() { Sanity.Requires(Schema.ColumnCount == Schema.ColumnNames.Length, "Schema name count mismatches."); Sanity.Requires(Schema.ColumnCount == Schema.ColumnTypes.Length, "Schema type count mismatches."); }