Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I have a VB6 application that writes a 2 dimensional array (40,1024) to a file using

 

FileNum2=freefile
Open FilePath For Binary As #FileNum2
Put #FileNum2, , VoltArr
Close #FileNum2

 

Where VoltArr is a 40 x 1024 array of double type.

 

I know need to open that file using .NET 2003.

 

I need to load the entire array at once just like I did in VB6 using

 

Dim FileNum As Integer
FileNum = FreeFile
Open FName For Binary As #FileNum
Get #FileNum, , ImageArr 'Populate array
Close #FileNum

 

Can someone point me in the right direction?

Edited by kcwallace
Go Beavs!!!
  • Leaders
Posted
.Net introduces streams to Visual Basic. I hear rumors that streams are faster (I don't doubt it, since under the hood, FileOpen, FileGet, and FileClose probably use FileStreams), and once you get used to them, it is quite possible that you might like the way they work better. The Visual Basic file access functions are considered "bad" and "vb-ish." They aren't exactly C# friendly (it might not be a problem for you, but it could become a problem when a C# programmer wants to help you with code or you search google for help with file access and come up with C# code). Ultimately it is a matter of preference, but I thought I would just give you more options and broaden your horizon and all that happy stuff.
[sIGPIC]e[/sIGPIC]
Posted

I tried to get the filesteam to work, I was successful, but never without having to loop through the entire array which is very time consuming.

 

I would love to make it work without the old code.

Go Beavs!!!
  • Leaders
Posted

You can read a whole bunch of bytes into a buffer (in this case our buffer could be an array of bytes).

       'Let's load 100 bytes of data into memory in one read operation
       Dim MyStream As New IO.FileStream("MyFile", IO.FileMode.Open, IO.FileAccess.Read)
       Dim MyData As Byte() = New Byte(99) {}
       MyStream.Read(MyData, 0, MyData.Length)
       MyStream.Close()

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...