zip in

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 ?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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 SuterSenior Software DeveloperCommented:
Use the DotNetZip library. It's very easy to use.

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.

Russ SuterSenior Software DeveloperCommented:
            ZipFile zip = new ZipFile(@"D:\Temp\");
            zip.AddFile(@"D:\Temp\sad-face.jpg", @"\sad\");

Open in new window

C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Russ SuterSenior Software DeveloperCommented:
Or in VB.NET

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

Open in new window

HalCHubAuthor Commented:
my  zipfile object does not have an additem method.
Russ SuterSenior Software DeveloperCommented:
That's an example using the DotNetZip library I provided a link for in the first post. The method is AddFile, not additem.
HalCHubAuthor Commented:
I miss typed... I dont have that method either
HalCHubAuthor Commented:
these samples target dotnet 2.0 and 3.0... most sites have dotnet 4.x
Russ SuterSenior Software DeveloperCommented:
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.
HalCHubAuthor Commented:
dotnet 4.5 is not backward compatible since it is missing most of the zipfile methods.
Russ SuterSenior Software DeveloperCommented:
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.
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.