Skip to content

Commit

Permalink
Add File.WriteAllBytes() (#45)
Browse files Browse the repository at this point in the history
* Add File.WriteAllBytes

* Add dot to end of xml doc
  • Loading branch information
MichielOda authored Feb 13, 2025
1 parent d161b07 commit 41c5221
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions FileSystem/FileIOLinux.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ public byte[] ReadAllBytes(string filePath)
}
}

/// <inheritdoc />
public void WriteAllBytes(string filePath, byte[] bytes)
{
File.WriteAllBytes(filePath, bytes);
}

/// <inheritdoc />
public string ReadAllText(string filePath)
{
Expand Down
7 changes: 7 additions & 0 deletions FileSystem/FileIOWin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ public byte[] ReadAllBytes(string filePath)
}
}

/// <inheritdoc />
public void WriteAllBytes(string filePath, byte[] bytes)
{
TryAllowWritesOnFile(filePath);
File.WriteAllBytes(filePath, bytes);
}

/// <inheritdoc />
public string ReadAllText(string filePath)
{
Expand Down
7 changes: 7 additions & 0 deletions FileSystem/IFileIO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ public interface IFileIO
/// <returns>A byte array containing the contents of the file.</returns>
byte[] ReadAllBytes(string filePath);

/// <summary>
/// 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.
/// </summary>
/// <param name="filePath">Path to the file.</param>
/// <param name="bytes">The bytes to write to the file.</param>
void WriteAllBytes(string filePath, byte[] bytes);

/// <summary>
/// Reads all text in a file. If file does not exist it will return an empty string.
/// </summary>
Expand Down

0 comments on commit 41c5221

Please sign in to comment.