From 61e82cdea4891695544d92061c7631da58d932e2 Mon Sep 17 00:00:00 2001 From: Michiel Oda Date: Wed, 12 Feb 2025 14:46:18 +0100 Subject: [PATCH 1/2] Add File.WriteAllBytes --- FileSystem/FileIOLinux.cs | 6 ++++++ FileSystem/FileIOWin.cs | 7 +++++++ FileSystem/IFileIO.cs | 7 +++++++ 3 files changed, 20 insertions(+) diff --git a/FileSystem/FileIOLinux.cs b/FileSystem/FileIOLinux.cs index 0427c4e..bcd39b1 100644 --- a/FileSystem/FileIOLinux.cs +++ b/FileSystem/FileIOLinux.cs @@ -118,6 +118,12 @@ public byte[] ReadAllBytes(string filePath) } } + /// + public void WriteAllBytes(string filePath, byte[] bytes) + { + File.WriteAllBytes(filePath, bytes); + } + /// public string ReadAllText(string filePath) { diff --git a/FileSystem/FileIOWin.cs b/FileSystem/FileIOWin.cs index fdbde11..3ee32fd 100644 --- a/FileSystem/FileIOWin.cs +++ b/FileSystem/FileIOWin.cs @@ -122,6 +122,13 @@ public byte[] ReadAllBytes(string filePath) } } + /// + public void WriteAllBytes(string filePath, byte[] bytes) + { + TryAllowWritesOnFile(filePath); + File.WriteAllBytes(filePath, bytes); + } + /// public string ReadAllText(string filePath) { diff --git a/FileSystem/IFileIO.cs b/FileSystem/IFileIO.cs index 3ee5bd8..4275013 100644 --- a/FileSystem/IFileIO.cs +++ b/FileSystem/IFileIO.cs @@ -124,6 +124,13 @@ public interface IFileIO /// A byte array containing the contents of the file. byte[] ReadAllBytes(string filePath); + /// + /// Creates a new file, writes the specified byte array to the file, and then closes the file. If the target file already exists, it is overwritten + /// + /// Path to the file. + /// The bytes to write to the file. + void WriteAllBytes(string filePath, byte[] bytes); + /// /// Reads all text in a file. If file does not exist it will return an empty string. /// From e3e12a9eacca5a4e024cd16c64a9a7720f0dc676 Mon Sep 17 00:00:00 2001 From: Michiel Oda Date: Wed, 12 Feb 2025 15:04:40 +0100 Subject: [PATCH 2/2] Add dot to end of xml doc --- FileSystem/IFileIO.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FileSystem/IFileIO.cs b/FileSystem/IFileIO.cs index 4275013..f3a5962 100644 --- a/FileSystem/IFileIO.cs +++ b/FileSystem/IFileIO.cs @@ -125,7 +125,7 @@ public interface IFileIO byte[] ReadAllBytes(string filePath); /// - /// Creates a new file, writes the specified byte array to the file, and then closes the file. If the target file already exists, it is overwritten + /// Creates a new file, writes the specified byte array to the file, and then closes the file. If the target file already exists, it is overwritten. /// /// Path to the file. /// The bytes to write to the file.