Get an certain block of bytes from a file
<p>For an assignment i have to send a file through xml by coding it with base64. 
I have to send the file in multiple parts. For that i want to get a block of bytes from that file.
I hoped that i could do that with a blocksize and blocknumber parameter.</p>

<p>But im not always getting bytes back, i gues im doing something wrong or just missed something stupid.</p>

<p>I created the following code:</p>

<pre><code>// int blocknumber (the blocknumber thats requested)
// int blocksize (by default we want to use 1024)

//Content of the block
ifstream is;
is.open(fullPath.c_str(), ios::binary);

// get length of file:
is.seekg(0, ios::end);
int length = is.tellg();

char* buffer = new char [blocksize];
//test if file is bigger then size
if (length &gt;= blocknumber * blocksize) {
    //skip to relevent part
    is.seekg(blocknumber * blocksize, ios::beg);
    is.read(buffer, blocksize);
}
</code></pre>

<p>This is a result that i get when i get data back</p>

<pre><code>blocknumber 0
GkXfo6NChoEBQveBAULygQRC84EIQoKIbWF0cm9za2FCh4ECQoWBAhhTgGcB
</code></pre>

<p>But with blocknumber 3 i get nothing.</p>
