diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-10-14 17:35:45 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-10-14 17:35:45 +0700 |
commit | 9b813d3d034fec5fc4bd15900c5e4005fc7b111c (patch) | |
tree | d125e9733043d5b042ecb73981da93a940510d73 /crypto | |
parent | Port latest X9 EC stuff from Java API (diff) | |
download | BouncyCastle.NET-ed25519-9b813d3d034fec5fc4bd15900c5e4005fc7b111c.tar.xz |
Close files after reading
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/test/src/openpgp/examples/test/AllTests.cs | 12 |
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) { |