I reading a file in a zip file using streams like this :
public static Stream ReadFile(Models.Document document, string path, string password, string fileName)
{
FileStream fsIn = System.IO.File.OpenRead(Path.Combine(path, $"{document.guid}.crypt"));
var zipFile = new ZipFile(fsIn)
{
//Password = password,
IsStreamOwner = true
};
var zipEntry = zipFile.GetEntry(fileName);
//zipEntry.AESKeySize = 256;
Stream zipStream = zipFile.GetInputStream(zipEntry);
return zipStream;
}
I'm having trouble closing the filestream fsIn as it is not available when I return from the ReadFile method and if I close it within the method the stream zipStream that I'm returning will be closed. How can I close fsIn but still read the data-stream returned from my method?