Edit

Share via


File.AppendAllBytes Method

Definition

Overloads

AppendAllBytes(String, Byte[])

Appends the specified byte array to the end of the file at the given path.

If the file doesn't exist, this method creates a new file.

AppendAllBytes(String, ReadOnlySpan<Byte>)

Appends the specified byte array to the end of the file at the given path.

If the file doesn't exist, this method creates a new file.

AppendAllBytes(String, Byte[])

Source:
File.cs

Appends the specified byte array to the end of the file at the given path.

If the file doesn't exist, this method creates a new file.

C#
public static void AppendAllBytes(string path, byte[] bytes);

Parameters

path
String

The file to append to.

bytes
Byte[]

The bytes to append to the file.

Exceptions

path or bytes is null.

path is empty.

The specified path, file name, or both exceed the system-defined maximum length.

The specified path is invalid (for example, it is on an unmapped drive).

An I/O error occurred while opening the file.

path specified a file that is read-only.

-or-

path specified a file that is hidden.

-or-

path specified a directory.

-or-

The caller does not have the required permission.

-or-

This operation is not supported on the current platform.

path is in an invalid format.

Applies to

.NET 10 and .NET 9
Product Versions
.NET 9, 10

AppendAllBytes(String, ReadOnlySpan<Byte>)

Appends the specified byte array to the end of the file at the given path.

If the file doesn't exist, this method creates a new file.

C#
public static void AppendAllBytes(string path, ReadOnlySpan<byte> bytes);

Parameters

path
String

The file to append to.

bytes
ReadOnlySpan<Byte>

The bytes to append to the file.

Exceptions

path is null.

path is empty.

The specified path, file name, or both exceed the system-defined maximum length.

The specified path is invalid (for example, it is on an unmapped drive).

An I/O error occurred while opening the file.

path specified a file that is read-only.

-or-

path specified a file that is hidden.

-or-

path specified a directory.

The caller does not have the required permission.

-or-

This operation is not supported on the current platform.

path is in an invalid format.

Applies to

.NET 10 and .NET 9
Product Versions
.NET 9, 10