zip in vb.net

I know how to add  a directory to an zip file but how to I add a file to an existing zip and how to I create a zip file with only item ?

Thanks
LVL 1
HalCHubAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Russ SuterCommented:
Use the DotNetZip library. It's very easy to use.

http://dotnetzip.codeplex.com/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HalCHubAuthor Commented:
I read thru it and I guess I am just dense and can not find my answer.

:(
0
Russ SuterCommented:
            ZipFile zip = new ZipFile(@"D:\Temp\test.zip");
            zip.AddFile(@"D:\Temp\sad-face.jpg", @"\sad\");
            zip.Save();

Open in new window

0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Russ SuterCommented:
Or in VB.NET

Dim zip As New ZipFile("D:\Temp\test.zip")
zip.AddFile("D:\Temp\sad-face.jpg", "\sad\")
zip.Save()

Open in new window

0
HalCHubAuthor Commented:
my  zipfile object does not have an additem method.
0
Russ SuterCommented:
That's an example using the DotNetZip library I provided a link for in the first post. The method is AddFile, not additem.
0
HalCHubAuthor Commented:
I miss typed... I dont have that method either
0
HalCHubAuthor Commented:
these samples target dotnet 2.0 and 3.0... most sites have dotnet 4.x
0
Russ SuterCommented:
dotnet 4.x is backward compatible.

Make sure you have a reference to the correct library.

I dug up a stackoverflow article that addresses this. Interestingly, at the end of the article it uses basically the same code that I have provided above.

http://stackoverflow.com/questions/27009422/how-to-add-ionic-zip-dll-in-c-net-project-and-use-it-to-create-a-zip-from-folde
0
HalCHubAuthor Commented:
dotnet 4.5 is not backward compatible since it is missing most of the zipfile methods. https://msdn.microsoft.com/en-us/library/system.io.compression.zipfile(v=vs.110).aspx
0
Russ SuterCommented:
Use the DotNetZip library I suggested in the first post. It's open source and with it you can do what you need to do in 3 lines of code. The library is compatible with .net 2.0 and up.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.