-1

I'm trying to use the features included within ZipFile but cannot get the namespace to include. I have a project and have referenced System.IO.Compression successfully but when trying to reference System.IO.Compression.FileSystem I get:

The type of namespace name 'FileSystem' does not exist in the namespace 'System.IO.Compression'

When I try to call ZipFile I get

The name 'ZipFile does not exist in the current context

I'm running .net 4.5.2 so I should have access to these functions. I don't know what's going on because it seems I'm doing everything correctly.

I've tried adding both references with Add Reference within Visual Studio which includes it within the References folder but I cannot use it within my handler.

Any help would be great, thanks!

My Using Directive currently:

using System.IO.Compression;

I am referencing the System.IO.Compression.FileSystem.dll within my project as well so this error is not making any sense.

Trying to use ZipFile:

string startPath = @"c:\example\start";
string zipPath = @"c:\example\result.zip";
string extractPath = @"c:\example\extract";

ZipFile.CreateFromDirectory(startPath, zipPath);
ZipFile.ExtractToDirectory(zipPath, extractPath);

The directories within the variables don't exist but that doesn't matter because ZipFile isn't even being found.  

Using Directives:

enter image description here

My Project and References:

enter image description here

Joe Scotto
  • 10,936
  • 14
  • 66
  • 136
  • A using directive is not the same as a reference. If the reference was successfully added (no warning icon on the reference and no warnings in the Error List), you are able to use the using directive to import a namespace from the referenced assembly from the project you added the reference to. – CodeCaster Feb 27 '17 at 14:49
  • Thanks for your very helpful comment... I have tried nearly every "solution" on SO, nothing seems to solve anything here. I'm new to this language and from my understanding it should be as simple as referencing it and using it. – Joe Scotto Feb 27 '17 at 14:50
  • Not to be rude but did you even read the question? I'm already referencing the `System.IO.Compression.FileSystem.dll` within my project. – Joe Scotto Feb 27 '17 at 14:53
  • I am `using System.IO.Compression` and then referencing the dll within my references. I don't see what's incorrect about this... – Joe Scotto Feb 27 '17 at 14:56
  • @CodeCaster Take a look at my updated question. – Joe Scotto Feb 27 '17 at 14:58
  • @CodeCaster I also just tried the question you linked and it does not solve anything because I'm doing everything according to the accepted answer on that question. – Joe Scotto Feb 27 '17 at 15:06
  • @CodeCaster Maybe my files aren't included correctly? Take a look at the screenshot I posted. – Joe Scotto Feb 27 '17 at 15:07
  • @CodeCaster Updated question. I'm editing emailer.ashx. – Joe Scotto Feb 27 '17 at 15:10
  • In your previous question you mentioned "I'm not using a solution or a project, I'm using just a standalone handler.ashx file". Which I don't fully understand but is probably the core problem. – H H Feb 27 '17 at 15:36
  • So, what kind of project is this, how is this `email.ashx` included in it? And if you can't answer that: create a [mcve] – H H Feb 27 '17 at 15:37
  • 1
    @CodeCaster Solved the issue by creating a new handler for that project. – Joe Scotto Feb 27 '17 at 15:40
  • Please don't ask the same question 3 times. – Paul-Sebastian Manole Sep 29 '20 at 16:03

1 Answers1

-1

The issue was that my Handler wasn't created for that project. I ended up creating a new handler for that project and I got access to everything within my References folder.

Joe Scotto
  • 10,936
  • 14
  • 66
  • 136
  • 1
    Can you be more specific? I have the same problem and I can't figure out how to solve it. – MattButtMatt May 03 '20 at 10:32
  • If you fixed your own problem, please also answer your own question, properly, as you would have expected someone else to have done it for you, in order for you to easily follow the answer and get a solution to the problem. Don't just *tell* us you've fixed it and leave it as is (practically unanswered). – Paul-Sebastian Manole Sep 29 '20 at 16:00