1 files changed, 10 insertions, 2 deletions
diff --git a/crypto/test/src/openpgp/examples/test/AllTests.cs b/crypto/test/src/openpgp/examples/test/AllTests.cs
index a2b582765..c20b599d7 100644
--- a/crypto/test/src/openpgp/examples/test/AllTests.cs
+++ b/crypto/test/src/openpgp/examples/test/AllTests.cs
@@ -274,12 +274,20 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp.Examples.Tests
private void CompareFile(string file1, string file2)
{
- byte[] data1 = Streams.ReadAll(File.OpenRead(file1));
- byte[] data2 = Streams.ReadAll(File.OpenRead(file2));
+ byte[] data1 = GetFileContents(file1);
+ byte[] data2 = GetFileContents(file2);
Assert.IsTrue(Arrays.AreEqual(data1, data2));
}
+ private byte[] GetFileContents(string name)
+ {
+ FileStream fs = File.OpenRead(name);
+ byte[] contents = Streams.ReadAll(fs);
+ fs.Close();
+ return contents;
+ }
+
private void CheckClearSigned(
string message)
{
|