I'm currently making an application which reads a file and extracts information from it. Whole files are embedded in this single file, and information about each file that is embedded is stored at a specific location within this file.
Expand|Select|Wrap|Line Numbers
- fs = new FileStream(@"File Location", FileMode.Open);
- br = new BinaryReader(fs);
- rtbOutput.AppendText("English Title: " + getLanguage(br));
Expand|Select|Wrap|Line Numbers
- public string getLanguage(BinaryReader reader)
- {
- byte[] data = ReadSection(reader, 1296, 256); // reader variable, offset, length
- return GetString(data);
- }
Expand|Select|Wrap|Line Numbers
- public static byte[] ReadSection(BinaryReader reader, int offset, int length)
- {
- reader.BaseStream.Seek(offset, SeekOrigin.Begin);
- return reader.ReadBytes(length);
- }
I would basically like to know how I seek past 256 bytes in a large file, without resorting to cycling through all the data and sticking it in a buffer. I've spent ages trying to think of a way to do this, and searching online to attempt to find a solution. I suppose what I'm looking for is somthing that lets me randomly access anywhere in a large file.
Apologies for in-efficient code and such, I'm reasonably new to C# :P