Click to See Complete Forum and Search --> : dynamically expand byte?
Techno
Jul 27th, 2005, 09:08 PM
is there a way to dynamically expand a byte[]?
The user will have no idea how big or small the data will be incoming from the server so in order to read the incoming data to the byte[] - you kinda need to know the exact size in order to grab the entire information...
Thanks :)
MrPolite
Jul 27th, 2005, 09:15 PM
you cant resize an array. You could declare a new one with a new size but then you'd have to copy all the content of the old array to it :(
a byte list in .NET 2.0 would be nicer I guess (it'd be like an arraylist)
Techno
Jul 27th, 2005, 09:57 PM
wish I could work with .NET 2.0 but unfortunatly cannot.
drats. So what way is there to recieve data of any size? as I understand when trying to read from a NetworkStream it has to be read into a byte[]
jmcilhinney
Jul 27th, 2005, 10:10 PM
I'm not 100% sure this would work but intuitively I would suggest you read the stream in chunks of a known size into a byte array and then you could call AddRange to add those bytes to an ArrayList. If you need a single array at the end then call ToArray on the ArrayList.
Techno
Jul 27th, 2005, 10:14 PM
interesting. I will try that.
whilst i am here this is what i am trying to do:
the client requests a list of files. the server gets these lists of files and for each file there is, it actually sends that filename to the client
the client recieves it however it for some reasons recieves it in one big long string... instead of just the short outbursts from the server....
this is why i was asking about how to dynamically increase the byte array... because I cannot for the life of me figure out why the client is recieving it as a big string.
so frustrating...
wierd thing is, if the client and server talk to each other (like an IM program) they recieve the text as they should....
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.