You are right, you cannot resize an array. You can copy a range of bytes from one array into a new array (see Array.Copy()), but that requires 2x the memory.
Adam may be right - depending on your needs - a MemoryStream may be the best choice for size and perf. The downside of a MemoryStream is that it's a little less direct to read from and write to. HTH. ______________________________ - David Lanouette - [EMAIL PROTECTED] "Excellence, then, is not an act, but a habit" - Aristotle > -----Original Message----- > From: Discussion of advanced .NET topics. > [mailto:[EMAIL PROTECTED] On Behalf Of Saad Rehmani > Sent: Wednesday, July 05, 2006 8:00 PM > To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM > Subject: Re: [ADVANCED-DOTNET] trim byte array > > I don't think you can resize managed arrays. > > If its super important, you can keep the byte array in > unmanaged space and call a realloc (or equivalent) on it. > > -s > -- > Saad Rehmani / Prodika / Dallas / TX / USA > > > -----Original Message----- > From: dave wanta <[EMAIL PROTECTED]> > Date: Thu, 6 Jul 2006 12:51:24 > To:ADVANCED-DOTNET@DISCUSS.DEVELOP.COM > Subject: [ADVANCED-DOTNET] trim byte array > > hi all, > does anyone know of an efficient way to trim a byte array? > > Here is what is happening. I'm reading in some binary data > into a dynamically expanding byte array, until all of the > data has been read into memory. I need to trim the byte array > to remove the trailing nulls. Because the amount of data is > large (100megs+), I don't want to simply create a 2nd > 100meg+ byte array in memory, and then copy it. So, is there > anyway to > 100meg+ trim > the existing byte array, and then return it? > > Thanks, > Dave > > =================================== > This list is hosted by DevelopMentorR http://www.develop.com > > View archives and manage your subscription(s) at > http://discuss.develop.com > =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com