Write int16 array(2,500,000) to binary file

dbAny

New member
Joined
Apr 27, 2005
Messages
3
Programming Experience
10+
I am trying to convert a vb6 app to a vb.net app.

I am having a problem with writing 2,500,000 16 bit values from an array to a file. In vb6 I used the

API instruction:

WriteFile lApiDataFile, binData(0), lSize, lApiReturn, ByVal 0&

However I cannot get this instruction to compile in vb.net I then tried to use:

Dim swFile As StreamWriter = File.CreateText("C:\myfile.ext")
dim binData(5000000) as binary

swFile.Write(data, 0, 5000000)
swFile.Flush()
swFile.Close()

This works fine with a binary data array. However I cannot figure out how to do this with a integer array
dim binData(2500000) as int16

When I do this I need to use a loop
For ii = 0 To 2500000
swFile.Write(binData(ii))
Next
which takes too long.

I am doing a "real time" application, and need to store ~ 10 Mbytes of data every 5 seconds. Thus I need to use the API or a flush instruction to ensure that the file write is completed before I can continue.

Can anyone suggest a way to:
how to use the API writefile in vb.net
How to "address" the int16 array with a byte array so that I can use .write without a loop
 
Back
Top