Hi,
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.
That is the code that I am using to attempt to read the language from the file, however, I cannot seek past (what seems) 256 bytes; nothing else seems to be available in the stream. The file itself is around 3.1mb, so I know that there is more that should be available to seek to, and I don't want to load the whole file in to a buffer (that would take ages, VB uses FileGet and doesnt need to load the whole thing in to a buffer).
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
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.
Code:
fs = new FileStream(@"File Location", FileMode.Open);
br = new BinaryReader(fs);
rtbOutput.AppendText("English Title: " + getLanguage(br));
Code:
public string getLanguage(BinaryReader reader)
{
byte[] data = ReadSection(reader, 1296, 256); // reader variable, offset, length
return GetString(data);
}
Code:
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
Comment