(English) Stream.Ream in Bytearray Problem

D

Daniel von Fersen

When I want to Read the Bytes 1000-2000 from a Stream into a ByteArray using

Stream.Read(byteArray,1000,2000)

they are written to the positions 1000-2000 in the byteArray.

but my Array is only 1000 items long Array(0-999), and i just want to have
the positions 1000-2000 from the stream!

How can i realize it that the bytes 1000-2000 are written to an Array of
length=1000

PS: The Stream is reading from the Internet

Thanx in advice
 
C

Cor Ligthert

Hi Daniel,

Sorry did misread the bytearray, however answer stays almost the same.

Why not read the 2000 bytes and than move it in your own application?

It seems for me so strange that you can bring a piece of program to a server
anywhere (by instance a Unix server) who is able to find that 1000 position
for you in the bytearray.

I think it is readed anyway.

Just my thought

Cor
 
H

Herfried K. Wagner [MVP]

* "Daniel von Fersen" <[email protected]> scripsit:
[...]

You don't need to mark English language posts as English here. This
group is per default English.
 
C

Cor Ligthert

Hi Herfried,

I thought what can Herfried say about this message, however you found
something.

LOL

And now I understand why he did it also in German, probably special for you.

(only for fun you know that however I add it before others misunderstand
it)

:)

Cor
 
C

Chris Dunaway

How can i realize it that the bytes 1000-2000 are written to an Array of
length=1000

Try this:

Stream.Seek(999,SeekOrigin.Begin)
Stream.Read(byteArray,0,1000)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top