質問

I have to make a simple zip file using Visual Studio and VB.NET 2003.

After some googling I got to this page: http://www.digioz.com/tutorials/zip_unzip_vbNET/Zip_and_Unzip_VB_NET_1.html wich basically provides me 3 DLLs with classes that are ready to zip files. When I try to create an instance of the class like the tutorial tells me to:

Dim zp As New CGZipLibrary.CGZipFiles

I get this error:

COM object with CLSID {293364BA-43F8-11D3-BC2D-4000000A2806} is either not valid or not registered.

Ideas? If anybody got a better/easier approach to zip files using VB.NET 2003 it would be helpful too.

Thanks.

EDIT:

Thanks for all who answered, but I've used a different approach than the suggested ones to zip my files. I used the Shell function of the Microsoft.VisualBasic.Interaction class like this:

Shell("zip -j " & fileName, AppWinStyle.Hide, True)

Thanks again for those who dedicated their time trying to help me!

役に立ちましたか?

解決

It looks like that library you are trying to use is an old COM dll. That means you have to register the dll first using regsvr32.exe before you can use it. However, I would recommend using a native .NET (managed) library. Unless it doesn't meet your needs, I'd simply recommend looking at the GZipStream class which is part of the .NET framework.

他のヒント

Have you tried this one? This is pretty good: ionic.zip.reduced, a dotnetzip library.

Example:

Using zip As ZipFile = New ZipFile()
     zip.AddFile("c:\photos\personal\7440-N49th.png")
     zip.AddFile("c:\Desktop\2008_Annual_Report.pdf")
     zip.AddFile("ReadMe.txt")
     zip.Save("MyZipFile.zip")
End Using

More VB.NET examples of Ionic.ZIP

UPDATE:

Your problem is that VS2003 can't use the targeting of the dll which was created in a newer (eg. VS2005) version of VS. For many have tried to use that, a tool was created which you can download here. For more information, visit this site.

Another option that I use in most of my projects is #ZipLib (SharpZipLib), downloads available here:

http://www.icsharpcode.net/opensource/sharpziplib/Download.aspx

Documentation and samples for both VB and C# are available at the same site. It has specific binary assemblies (dll) for .NET framework 1.1, as well as later versions. It's likely that some of the other libraries that you're run across are compiled for .NET 2.0 or later, which won't work in VS2003.

Don't let the name fool you -- it's written in C# (hence the name) but the compiled assemblies work just fine in VB.NET. It supports Zip, GZip, tar, and BZip2 archives.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top