C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Note: The File.Open method is used to create the "file.bin" file, and this is passed to the BinaryWriter constructor.
Finally: The For Each loop simply writes each element in the array to the file.
For Each, ForVB.NET program that uses BinaryWriter
Imports System.IO
Module Module1
Sub Main()
' Write this array to the file.
Dim array() As Int32 = {1, 4, 6, 7, 11, 55, 777, 23, 266, 44, 82, 93}
' Create the BinaryWriter and use File.Open to create the file.
Using writer As BinaryWriter = New BinaryWriter(File.Open("file.bin", FileMode.Create))
' Write each integer.
For Each value As Int32 In array
writer.Write(value)
Next
End Using
End Sub
End Module
Result: The file "file.bin" is created in the current directory. It contains some data.