Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understand the question correctly, you want to chop the existing array into arrays of (at most) 100k elements, and put those arrays in the array list?</p> <pre><code>ArrayList Split(byte[] filebytes, int range) { range *= 1000; int pos = 0; int remaining; ArrayList result = new ArrayList(); while ((remaining = filebytes.Length - pos) &gt; 0) { byte[] block = new byte[Math.Min(remaining, range)]; Array.Copy(filebytes, pos, block, 0, block.Length); result.Add(block); pos += block.Length; } return result; } </code></pre> <p>Change 1000 to 1024 if that was your intention :)</p> <p>I can't really think of a reason why you'd want to do something like this though. Loading one huge array of bytes and <em>then</em> splitting into blocks is rather inefficient if you could have split them into 100k blocks while reading your data.</p> <hr> <p>Regarding your comment: sending an entire file to a socket should be much simpler than you're making it to be. I have no way of testing, but this should work in .NET 1.1.</p> <pre><code>private void SendFileToSocket(string fileName) { Socket socket = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); using (socket) { socket.Connect("server.domain.com", 12345); using (NetworkStream networkStream = new NetworkStream(socket)) using (FileStream fileStream = File.OpenRead(fileName)) { byte[] buffer = new byte[32768]; while (true) { int bytesRead = fileStream.Read(buffer, 0, buffer.Length); if (bytesRead == 0) break; networkStream.Write(buffer, 0, bytesRead); } } } } </code></pre> <p>The buffer size is a little arbitrary, but it should be large enough.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload