Close FileStream opened by Get-FileHash (#4175)

Fix #4174
This commit is contained in:
Keith Hill
2017-07-06 22:58:23 -07:00
committed by Jason Shirk
parent 1688703caf
commit fa02e84d66
@@ -121,10 +121,11 @@ namespace Microsoft.PowerShell.Commands
{
byte[] bytehash = null;
String hash = null;
Stream openfilestream = null;
try
{
Stream openfilestream = File.OpenRead(path);
openfilestream = File.OpenRead(path);
bytehash = hasher.ComputeHash(openfilestream);
hash = BitConverter.ToString(bytehash).Replace("-","");
@@ -138,6 +139,10 @@ namespace Microsoft.PowerShell.Commands
path);
WriteError(errorRecord);
}
finally
{
openfilestream?.Dispose();
}
}
}