I am trying to extract a zip file in C#.
I have included using System.IO.Compression;
but when I enter System.IO.Compression.
the only methods i see are CompressionLevel, CompressionMode, DeflateStream, and GzipStream.
ZipFile.ExtractToDirectory
is not available. Is it deprecated?
Asked
Active
Viewed 906 times
4

Panos
- 63
- 8
-
Can you post your full code? `ExtractToDirectory` is an extension of `ZipArchive` and located in the "System.IO.Compression" namespace – maccettura Apr 05 '17 at 19:41
-
Did you also add a reference to the correct Assembly (`System.IO.Compression.FileSystem` as per the docs: https://msdn.microsoft.com/en-us/library/hh485723(v=vs.110).aspx)? – UnholySheep Apr 05 '17 at 19:42
-
Specifically [this answer](http://stackoverflow.com/a/21039548/27414), as the accepted answer in that question is pretty out of date. – Jon B Apr 05 '17 at 19:42
-
I believe that this was only added in .Net 4 or possibly 4.5. What version are you targeting? See the "Other Versions" dropdown on [MSDN](https://msdn.microsoft.com/en-us/library/system.io.compression(v=vs.110).aspx) – Basic Apr 05 '17 at 19:43
-
I read that it was added on version 4.5. I tried using 4.5.2 and 4.6.1. I have used the System.IO.Compression namespace – Panos Apr 05 '17 at 19:48
-
This question is not a duplicate. I am not asking how to unzip. I am asking why a specific method is not available. – Panos Apr 05 '17 at 19:51
-
@Panos - fair enough. Sorry for the itchy trigger finger. – Jon B Apr 05 '17 at 19:52
1 Answers
8
Make sure you have a reference to System.IO.Compression.FileSystem
.
Using VS2015 and creating a console app does not add this by default.

Jon B
- 51,025
- 31
- 133
- 161