summary refs log tree commit diff
path: root/crypto
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2015-10-14 17:35:45 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2015-10-14 17:35:45 +0700
commit9b813d3d034fec5fc4bd15900c5e4005fc7b111c (patch)
treed125e9733043d5b042ecb73981da93a940510d73 /crypto
parentPort latest X9 EC stuff from Java API (diff)
downloadBouncyCastle.NET-ed25519-9b813d3d034fec5fc4bd15900c5e4005fc7b111c.tar.xz
Close files after reading
Diffstat (limited to 'crypto')
-rw-r--r--crypto/test/src/openpgp/examples/test/AllTests.cs12
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)
 		{