Skip to content

Commit a4151d1

Browse files
committed
Fixes issue #604
1 parent d46ffcc commit a4151d1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/EPPlus/ExcelPackageAsync.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@ public async Task LoadAsync(string filePath, CancellationToken cancellationToken
5454
/// <param name="cancellationToken">The cancellation token</param>
5555
public async Task LoadAsync(FileInfo fileInfo, string Password, CancellationToken cancellationToken = default)
5656
{
57-
var stream = fileInfo.OpenRead();
58-
await LoadAsync(stream, RecyclableMemory.GetStream(), Password, cancellationToken).ConfigureAwait(false);
57+
using (var stream = fileInfo.OpenRead())
58+
{
59+
await LoadAsync(stream, RecyclableMemory.GetStream(), Password, cancellationToken).ConfigureAwait(false);
60+
stream.Close();
61+
}
5962
}
6063
/// <summary>
6164
/// Loads the specified package data from a stream.
@@ -77,8 +80,11 @@ public async Task LoadAsync(string filePath, string password, CancellationToken
7780
/// <param name="cancellationToken">The cancellation token</param>
7881
public async Task LoadAsync(FileInfo fileInfo, Stream output, string Password, CancellationToken cancellationToken = default)
7982
{
80-
var stream = fileInfo.OpenRead();
81-
await LoadAsync(stream, output, Password, cancellationToken).ConfigureAwait(false);
83+
using (var stream = fileInfo.OpenRead())
84+
{
85+
await LoadAsync(stream, output, Password, cancellationToken).ConfigureAwait(false);
86+
stream.Close();
87+
}
8288
}
8389
/// <summary>
8490
/// Loads the specified package data from a stream.

0 commit comments

Comments
 (0)