This topic has not yet been rated - Rate this topic

FileSystem.WriteAllBytes Method

Writes data to a binary file.

Namespace:  Microsoft.VisualBasic.FileIO
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
public static void WriteAllBytes(
	string file,
	byte[] data,
	bool append
)

Parameters

file
Type: System.String
String. Path and name of the file to be written to. Required.
data
Type: System.Byte[]
Byte. Data to be written to the file. Required.
append
Type: System.Boolean
Boolean. Whether to append or overwrite data. Default is False. Required.

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

If the append parameter is True, it appends the data to the file; otherwise data in the file is overwritten.

If the specified path, excluding the file name, is not valid, a DirectoryNotFoundException exception will be thrown. If the path is valid but the file does not exist, the file is created.

The following table lists an example of a task involving the My.Computer.FileSystem.WriteAllBytes method.

To

See

Write to a binary file

How to: Write to Binary Files in Visual Basic

This example appends the data array CustomerData to the file CollectedData.

My.Computer.FileSystem.WriteAllBytes _
("C:\MyDocuments\CustomerData", CustomerData, True)


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