Skip to content

Commit

Permalink
Rewrite ConvertStreamToByteArray to avoid CA2022
Browse files Browse the repository at this point in the history
  • Loading branch information
Deadpikle committed Oct 16, 2024
1 parent 2c1cb7c commit 0b90eec
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/NetSparkle/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ public static string GetFullBaseDirectory()
/// <returns>a byte[] array of the data in the given stream</returns>
public static byte[] ConvertStreamToByteArray(Stream stream)
{
// read the data
byte[] data = new byte[stream.Length];
stream.Read(data, 0, data.Length);
return data;
using (MemoryStream ms = new MemoryStream())
{
stream.CopyTo(ms);
return ms.ToArray();
}
}

/// <summary>
Expand Down

0 comments on commit 0b90eec

Please sign in to comment.