EasyZip & C#


EasyZip & C#

Postby xram on Mon Sep 15, 2003 8:35 am

Hi there, i"m creating a web site using ASP.NET and C#. The site involves people uploading zipped files and the server then unzipping them etc. Is there any way I can use EasyZip whilst still using C#? Or would I have to write the code that uses EasyZip in VB?

The code I currently have is this:

private void ExtractZip(String zipFile)
{ Object zip = Server.CreateObject("aspZip.EasyZIP");
zip.ZipFileName = zipFile;
zip.UnzipBinaryWrite();
}

But I get the error: "object" does not contain a definition for "ZipFileName" [xx(]

Does this happen because the page is in C# and the aspZip.EasyZIP component is in VB(?)? Or as it"s a DLL should it not matter? (I"m quite the asp noob as you can probably gather) Or am i just missing a namespace declaration or some kind of include statement? [:I]

OK, enough questions... thanks in advance if you can help [:D]
xram
 
Posts: 3
Joined: Mon Sep 15, 2003 8:25 am

Postby xram on Mon Sep 15, 2003 8:38 am

oh and one last thing... I successfully used the contents.aspx page to see what was in the test.zip file that comes in the d/l so i'm assuming its installed correctly [:)]
xram
 
Posts: 3
Joined: Mon Sep 15, 2003 8:25 am

Postby xram on Mon Sep 15, 2003 8:53 am

ok, more hunting done and I see that I can't use the UnZIPBinaryWrite method unless I have a registered version. So....

private void ExtractZip(String zipFile)
{ Object ZIP = Server.CreateObject("aspZip.EasyZIP");
ZIP.ZipFileName = zipFile;
}

still gives me the same error as before: 'object' does not contain a definition for 'ZipFileName'

interestingly, I can change the argument for CreateObject to just about anything with no difference to the error message, should that be happening?
xram
 
Posts: 3
Joined: Mon Sep 15, 2003 8:25 am

Postby John on Mon Sep 15, 2003 9:05 am

On ASP code the Create method is called automatically by the On_StartPage event, as you don't have an automated call on ASP.NET you must call it by your self:

private void ExtractZip(String zipFile)
{ Object zip = Server.CreateObject("aspZip.EasyZIP");
zip.Create();
zip.ZipFileName = zipFile;
// UnZipBinaryWrite just works on ASP, does not work for ASP.NET
// zip.UnzipBinaryWrite();

//.. Do your code and then Destroy it
zip.Destroy();

}
John
 
Posts: 1313
Joined: Wed Oct 31, 2001 10:23 am
Location: Spain

Postby stworsham on Fri Sep 03, 2004 5:31 pm

I am also having the same problem. The Server.CreateObject method does not expose the EasyZip Interop DLL properties and methods. I have added the reference to System.Runtime.InteropServices namespace, but this makes no difference.

How can the DLL methods be exposed through C#[?]
stworsham
 
Posts: 3
Joined: Fri Sep 03, 2004 5:24 pm
Location: USA

Postby John on Fri Sep 03, 2004 5:51 pm

You should import the COM+ object of aspEasyZIP.dll, this will create the interop.

Here is a sample done in VB.NET, should be easy to reconvert to C#

http://www.mitdata.net/files/ZIPSample_VB_NET.ZIP
John
 
Posts: 1313
Joined: Wed Oct 31, 2001 10:23 am
Location: Spain

Postby stworsham on Sat Sep 04, 2004 4:18 pm

Thanks. I have looked at this sample and I have imported the EasyZip DLL into my project as a reference object. When I build the project, errors are generated for all the EasyZip methods. They cannot be found.

Apparently VB.Net is more forgiving in its COM interfaces.

Have you tried converting the VB.Net sampe to a C# project? I am extremely interested in making this work.
stworsham
 
Posts: 3
Joined: Fri Sep 03, 2004 5:24 pm
Location: USA

Postby stworsham on Sun Sep 05, 2004 6:10 pm

After messing around with it for a little while, I found a successful way to invoke and implement the EasyZip DLL in C#.

It was a simple solution that should never have caused confusion in the first place.

After importing the DLL as a COM object, use this line to instantiate the EasyZip object:

aspZIP.EASYZIP zip = new aspZIP.EASYZIPClass();

This will expose all the class events.
stworsham
 
Posts: 3
Joined: Fri Sep 03, 2004 5:24 pm
Location: USA


Return to Zip

Who is online

Users browsing this forum: No registered users and 1 guest

cron

Fatal error: Not able to open ./cache/data_global.php in D:\Hosting\6480136\html\ForosBB3\includes\acm\acm_file.php on line 106