From 9b813d3d034fec5fc4bd15900c5e4005fc7b111c Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Wed, 14 Oct 2015 17:35:45 +0700 Subject: Close files after reading --- crypto/test/src/openpgp/examples/test/AllTests.cs | 12 ++++++++++-- 1 file 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) { -- cgit 1.4.1