This is pretty simple, actually. Basically, you would simply use a method
like the following:
/// <summary>
/// Copies a a section of the data in input into output.
/// </summary>
/// <param name="input">The Stream to copy data from.</param>
/// <param name="output">The Stream to copy data to.</param>
/// <param name="offset">The byte offset at which the copy should
bein.</param>
/// <param name="count">The number of bytes to copy</param>
/// <remarks>
/// This method does not close either stream, that is left up to the caller.
/// It also does not re-seek the stream, that too is left to the caller
/// </remarks>
void CopySegment(Stream input, Stream output, long offset, int count)
{
//allocates a new buffer to store the data between the streams
byte[] buffer = new byte[count];
//moves the input stream's Position to the offset you wish to read from
input.Seek(offset,SeekOrigin.Begin);
//Reads data from the input stream into a byte buffer
input.Read(buffer,0,count);
//Write the buffer to the output stream
output.Write(buffer,0,count);
//Flush the stream to disk
output.Flush();
}
you must simply pass in the stream of the file you are reading from (input),
the stream to the file or memory buffer you want to write to (output), the
offset of the data in the input stream, and the number of bytes you want to
transfer.
Also, in production code, you should include try catch blocks to handle
errors, i'm electing to leave it out for clarity here.