-
Book Overview & Buying
-
Table Of Contents
Visual Basic Quickstart Guide
By :
We will continue to utilize the two different methods for VB.NET and older VB family members. For VB.NET, we will use the File class from the System.IO namespace to read binary data from files. For VBA and VB6, we will use the file number operations we saw in the previous sections. VBScript can use ADODB.stream to read binary data from files, but we will leave it out of this section due to its complexity.
The File class also provides a method that makes reading binary data from a file in a single line easy. The ReadAllBytes method allows you to receive an array of bytes representing the data from the file:
Imports System.IO Dim myFile As String = "C:\Path\File.dat" Dim bData() As Byte bData = File.ReadAllBytes(myFile)
To read binary data from files in VB.NET, you can also use the FileStream class from the System.IO namespace. Here’s an example of how to read binary data from a file with a FileStream object:
Imports System.IO...