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