Hi Dave, Do you want the byte[] to be trimmed or the stream iself? In case of the latter, you can read the data in small chuncks, and do special handling for the 0x0 character. 1) If no other data was read before, you can skip all 0x0 bytes 2) Otherwise count the # contigious 0x0 bytes in an integer. If some other char was read you have to output the counted # 0x0 bytes and reset the counter.
This algorithm prevents the buffering of a large amount of data just to be able to trim the data afterwards. May be it helps. Regards, Piewie ----- Original Message ----- From: "dave wanta" <[EMAIL PROTECTED]> To: <ADVANCED-DOTNET@DISCUSS.DEVELOP.COM> Sent: Thursday, July 06, 2006 7:51 PM 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 trim | the existing byte array, and then return it? | | Thanks, | Dave | | =================================== | This list is hosted by DevelopMentorĀ® 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