Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[API Proposal]: File.AppendAllBytes #84532

@Symbai

Description

@Symbai

Background and motivation

The File class has all methods for bytes which also exist for text except of appending data. Not only that it fits into the api surface by filling this gap is also saves us writing more than one line of code.

API Proposal

namespace System.IO;

public class File
{
+    public static void AppendAllBytes(string path, ReadOnlySpan<byte> data);
+    public static Task AppendAllBytesAsync(string path, ReadOnlyMemory<byte> data, CancellationToken cancellationToken = default);
     public static void AppendAllText(string path, string? contents);
     public static Task AppendAllTextAsync(string path, string? contents, CancellationToken cancellationToken = default);
}

API Usage

byte[] data = File.ReadAllBytes("C:\\1.bin");

File.AppendAllBytes("C:\\2.bin", data);

Alternative Designs

No response

Risks

No response

Metadata

Metadata

Assignees

Labels

api-approvedAPI was approved in API review, it can be implementedarea-System.IOgood first issueIssue should be easy to implement, good for first-time contributorshelp wanted[up-for-grabs] Good issue for external contributors

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions