This topic has not yet been rated - Rate this topic

FileSystem.ReadAllBytes Method

Returns the contents of a file as a byte array.

Namespace:  Microsoft.VisualBasic.FileIO
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
public static byte[] ReadAllBytes(
	string file
)

Parameters

file
Type: System.String
String. File to be read. Required.

Return Value

Type: System.Byte[]
Byte array containing the contents of the file.

For more detailed information, see the Visual Basic topic My.Computer.FileSystem.ReadAllBytes Method.

The ReadAllBytes method of the My.Computer.FileSystem object allows you to read from a binary file. The contents of the file are returned as a byte array.

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 following table lists examples of tasks involving the My.Computer.FileSystem.ReadAllBytes method.

To

See

Read from a binary file

How to: Read From Binary Files in Visual Basic

This example reads from the file C:/Documents and Settings/selfportrait.jpg.

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


Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ