7

I' like to use the dll System.IO.Compression.FileSystem.dll in my project

file

the .net framework version is 4.5 and the os is 64. The problem is that the dll is not found. config What is the solution?

Lamloumi Afif
  • 8,941
  • 26
  • 98
  • 191
  • Do you have full .NET 4.5 installed? It's not Client Profile? Is the screenshot you provided showing that you can ask for the DLL but then it cannot be found? – DonBoitnott May 31 '13 at 15:36
  • You are getting assembly name and namespaces mixed up. Using should be the Namespace which is just System.IO.Compression – sgmoore May 31 '13 at 15:37
  • 2
    @DonBoitnott I believe they got rid of the Client Profile stuff with 4.5. – Joe Enos May 31 '13 at 15:41
  • 1
    @JoeEnos I just found that in a different search; you are correct. – DonBoitnott May 31 '13 at 15:42

4 Answers4

17

The namespace is not the same as the dll name (assembly name). from the MSDN page you linked

Namespace: System.IO.Compression
Assembly: System.IO.Compression.FileSystem (in System.IO.Compression.FileSystem.dll)

So the namespace you need to include is System.IO.Compression not System.IO.Compression.FileSystem. Take off the FileSystem part from your using statement and it will solve your problem.


If people are down-voting me because the OP said "The problem is that the dll is not found." I think the OP is not using the correct word choice, if the problem really was that the DLL could not be found there would be a exclamation point by the assembly name which the original screenshot does not have

See the original image below

Original Image
(click for larger view)

Compare that to my screenshot I created that would show up if the DLL really was not found, note the exclamation point I have that the original screenshot does not.

enter image description here

Scott Chamberlain
  • 124,994
  • 33
  • 282
  • 431
  • 1
    @Lamloumi Ok, what about it. The Namespace is still `System.IO.Compression`, the problem [your screenshot shows](http://i.stack.imgur.com/0auH7.jpg) is that you have a red underline under `FileSystem`, that is because that part is not part of the namespace name. The full path of the function you linked would be `System.IO.Compression.ZipFile.CreateFromDirectory(String, String)` not `System.IO.Compression.FileSystem.ZipFile.CreateFromDirectory(String, String)` – Scott Chamberlain May 31 '13 at 15:54
  • sorry i misunderstood you :) – Lamloumi Afif May 31 '13 at 15:59
4

in the System.IO.Compression there's no such class as FileSystem check it out the link on the msdn

the classes available are:

  • DeflateStream Provides methods and properties for compressing and decompressing streams by using the Deflate algorithm.
  • GZipStream Provides methods and properties used to compress and decompress streams.
  • ZipArchive Represents a package of compressed files in the zip archive format.
  • ZipArchiveEntry Represents a compressed file within a zip archive.
  • ZipFile Provides static methods for creating, extracting, and opening zip archives.
  • ZipFileExtensions

if your goal is to use compression of file or stream use the GZipStream class.

However remove the FileSystem from the using statement:

using System.IO.Compression;

Anyway as Joe Enos has pointed out classes from the Compression namespace have been taken out the Client Profile from the framework 4.5

Below the Version Information from the msdn about the GZipStream:

.NET Framework Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile Supported in: 4, 3.5 SP1

codingadventures
  • 2,924
  • 2
  • 19
  • 36
2

A new nuget package is coming out. Check this out :)

https://www.nuget.org/packages/System.IO.Compression.ZipFile

lnaie
  • 1,011
  • 13
  • 16
-3

Adding reference to System.IO.Compression.dll solved this issue for me.