Page 1 of 1

Reading specified areas?

Posted: Sun Jun 29, 2008 1:19 am
by DEEhunter
In C# how would I make my file stream read from only 0x148 to EOF and be able to write it to a file?

Posted: Sun Jun 29, 2008 1:46 pm
by OwnZ joO
Easiest way would be

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();

Posted: Sun Jun 29, 2008 2:06 pm
by Patrickssj6
Or just use an exception to stop it...

Posted: Sun Jun 29, 2008 2:58 pm
by DEEhunter
How about reading from the file stream and showing it in a picture box once the file is opened.