Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do you zip a folder using VB.net?

Posted on 2010-11-09
7
Medium Priority
?
638 Views
Last Modified: 2012-05-10
Is there a way to do this without using a 3rd party application?

Thanks
Phil
0
Comment
Question by:targunp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 7

Expert Comment

by:EYoung
ID: 34098357
Here is a way to zip using a Process:

    Private Sub srZip_CSV_File()
        'Zip RetailCustLineData.csv to RetailCustLineData.zip and pause until completed before continuing
        Dim P As New Process
        P.StartInfo.FileName = "C:\Program Files\WinZip\WINZIP32.EXE"
        P.StartInfo.Arguments = "-min -a C:\FTP-Data\Icentrix\RetailCustLineData.zip C:\FTP-Data\Icentrix\RetailCustLineData.csv"
        P.Start()
        P.WaitForExit()
        ' ...continue with other stuff...
    End Sub
0
 
LVL 7

Expert Comment

by:EYoung
ID: 34098372
Be sure to change this line to zip a folder:  (example)

P.StartInfo.Arguments = "-min -a C:\FTP-Data\Icentrix\<folder_name.zip> C:\FTP-Data\Icentrix\*.*"

Change it to your names.
0
 
LVL 13

Expert Comment

by:AngryBinary
ID: 34098414
There aren't any built-in .NET classes that handle ZIP compression. Also, the "built-in" zip compression for windows (Right click -> send to -> Compressed Folder) does not have a command line interface unless you've downloaded the MS support tool kit.

So, you will either need to download a 3rd party .NET zip library (such as http://www.icsharpcode.net/opensource/sharpziplib/ - if you download the compiled assembly, it will work with a VB.NET application) or make a call to a 3rd party zip utility with a command line interface  (or Microsoft's COMPRESS utility, if you do have the support tools installed) using "Process.Start(executableFile, args)".
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 70

Expert Comment

by:Éric Moreau
ID: 34098780
0
 
LVL 14

Accepted Solution

by:
raja_ind82 earned 1000 total points
ID: 34099970
0
 

Author Comment

by:targunp
ID: 34160915
Google gzip, that is the best solution.
0
 

Author Closing Comment

by:targunp
ID: 34160921
Gzip is better, the example posted shows you how to pack a file, not pack and compress. Still thank you for your help
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
The viewer will learn how to count occurrences of each item in an array.

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question