Can anyone explain this?
Asked
Active
Viewed 638 times
2
-
You could use `using (GZipStream compStream = new GZipStream(outFile, CompressionMode.Compress)) { //your code }` instead of using the compStream.close this would take care of any disposal needed from your current open stream. – Prix Jun 15 '11 at 07:04
-
@Prix: Thanks. I was just trying to understand why. – richard Jun 15 '11 at 07:16
1 Answers
1
when you close the GZip stream, it's closes the underlying file stream, the exception is thrown because you already closed the file stream. you don't need to close both of them, just close the gzip stream

Waleed
- 3,105
- 2
- 24
- 31
-
-
simply cause the GZipStream.Close will try to close the underlying file stream – Waleed Jun 15 '11 at 07:05