[RESOLVED] [2005] BinaryWriter question
I've never used it before and now need to due to the amount of data that needs to be outputted takes too long from excel. I was just wondering if there is a quick way to say output the entire contents of a List (of Single). (I know it doesn't matter what the variable is - was just to clarify).
Just as an example: Here is a simple example of what I'm sort of dealing with:
VB Code:
Private Structure ImageData
Dim XCoordinates As List(Of Integer)
Dim YCoordinates As List(Of Integer)
End Structure
Dim Cases(4) As ImageData
Dim myRnd As New Random
Dim myCountX As Integer = 0
For i As Integer = 0 To 4 'Populate with dummy data
Cases(i).XCoordinates = New List(Of Integer)
Cases(i).YCoordinates = New List(Of Integer)
myCountX = myRnd.Next(150, 400)
For x As Integer = 0 To myCountX
Cases(i).XCoordinates.Add(myRnd.Next(20, 150))
Cases(i).YCoordinates.Add(myRnd.Next(20, 150))
Next
Next
Dim myBinary As New IO.BinaryWriter(System.IO.File.Open("D:\My Documents\binary.txt", IO.FileMode.Create))
'I have to write the Count and store that info too?
'Do I just add a loop here and output the binary data? Or is there a better way to output all the data?
'i.e. Cases(0).XCoordinates.Output All Data (or something)
myCountX = Cases(k).XCoordinates.Count
Re: [RESOLVED] [2005] BinaryWriter question
try this. You will probably need to play around with it to get it to fit your needs, but you can get the idea.
VB Code:
Dim myBinary As New IO.BinaryWriter(System.IO.File.Open("D:\My Documents\binary.txt", IO.FileMode.Create))
Dim str As IO.Stream = myBinary.BaseStream
str.Write(Cases(0).XCoordinates.ToArray, 0, Cases(0).XCoordinates.Count - 1)
myBinary.Flush()
myBinary.Close()