سؤال

I'm trying to read two matrix from a binary file (256x256x2) but couldn't do it without iterating 256x256x2 times which takes too long. For now I just want to check the data and make sure it's corect (not only zeros). This is what I have:

Dim msg As String
Dim b(256 * 256 * 2) As Byte
Dim i As Int32
Dim reader As New BinaryReader(File.Open(path, FileMode.Open))
b = reader.ReadBytes(b.Length)
For i = 0 To b.Length
    msg = msg & ", " & b(i)
Next
TextBox1.Text = msg

The data on the matrix are just numbers (0-255).

What's the best way to save the data to an array, if possible with the format

array[matrixno][row][column]

because later I will need to find specific values of the array based on its position.

PS. I'm using the old Visual Studio 2003 because that's what I have available.

Thanks

Edit:

Figured out what was taking long was actually displaying all the bytes, problem solved!

هل كانت مفيدة؟

المحلول

Almost two years later, it's time to take this off the unanswered list.

The loop worked just fine, the problem was printing every single value read instead of simpling saving it to a variable.

Lesson learned (long ago): Printing takes time.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top