Reading specified areas?
Posted: Sun Jun 29, 2008 1:19 am
In C# how would I make my file stream read from only 0x148 to EOF and be able to write it to a file?
Visit remnantmods.com for more information
http://www.halomods.info/
Code: Select all
// open your file for reading
FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
// create the new file for writing
FileStream newFile = new FileStream(newFilePath, FileMode.Create, FileAccess.Write);
BinaryWriter bw = new BinaryWriter(newFile);
br.BaseStream.Position = 0x148;
int bytesToRead = (int)br.BaseStream.Length - 0x148;
bw.Write(br.ReadBytes(bytesToRead));
br.Close();
bw.Close();