Export (0) Print
Expand All
5 out of 26 rated this helpful - Rate this topic

How to: Read From Binary Files in Visual Basic 

The My.Computer.FileSystem object provides the ReadAllBytes method for reading from binary files.

To read from a binary file

  • Use the ReadAllBytes method, which returns the contents of a file as a byte array. This example reads from the file C:/Documents and Settings/selfportrait.jpg.

    My.Computer.FileSystem.ReadAllBytes _
    ("C:/Documents and Settings/selfportrait.jpg")
    
    

Robust Programming

The following conditions may cause an exception to be thrown:

Do not make decisions about the contents of the file based on the name of the file. For example, the file Form1.vb may not be a Visual Basic source file.

Verify all inputs before using the data in your application. The contents of the file may not be what is expected, and methods to read from the file may fail.

See Also

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.