Reading specified areas?

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Post Reply
User avatar
DEEhunter





Posts: 897
Joined: Sun Jun 19, 2005 4:04 pm
Location: 127.0.0.1
Contact:

Reading specified areas?

Post 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?
Image

Deviantart | My City | Wmclan | Gamertag | [url=irc://irc.halomods.com/melon]#melon[/url]
OwnZ joO




Articulatist 500

Posts: 980
Joined: Thu Nov 10, 2005 4:24 pm

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




Pi Collaborator

Posts: 5426
Joined: Sat Jul 24, 2004 12:12 pm
Location: I'm a Paranoid
Contact:

Post by Patrickssj6 »

Or just use an exception to stop it...
...left for good
User avatar
DEEhunter





Posts: 897
Joined: Sun Jun 19, 2005 4:04 pm
Location: 127.0.0.1
Contact:

Post by DEEhunter »

How about reading from the file stream and showing it in a picture box once the file is opened.
Image

Deviantart | My City | Wmclan | Gamertag | [url=irc://irc.halomods.com/melon]#melon[/url]
Post Reply