Results 1 to 5 of 5

Thread: dynamically expand byte?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    dynamically expand byte?

    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

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: dynamically expand byte?

    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)
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: dynamically expand byte?

    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[]

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: dynamically expand byte?

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: dynamically expand byte?

    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....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width