Click here to Skip to main content
15,924,452 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I have a file in the folder c:\temp called Value.TXT. I want to winzip this file automatically. How/what is the best way to winzip this file via VB.Net
Posted
Comments
Sergey Alexandrovich Kryukov 24-Jul-13 9:54am    
It's not "winzipping", it's just "zipping". Winzip is just the application which you don't need to use.
—SA

Hi,

The answer of OriginalGriff is correct, but the ZipFile class is only available from .NET 4.5, so if you don't use .NET 4.5, you should use a 3rd party library such as:
SharpZipLib[^]
DotNetZip[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 24-Jul-13 9:56am    
5ed.
—SA
Thomas Daniels 24-Jul-13 9:57am    
Thank you!
If this is truly VB.NET then I wouldn't recommend it - either the file will be pottentially written by a large number of users, or it will be located on a client PC where your VB code can't get access to it.

If this is a WinForms VB application, then it's pretty simple: MSDN: ZipFile class[^] includes an example.
 
Share this answer
 
Comments
Thomas Daniels 24-Jul-13 9:41am    
Your answer is correct, but I voted 4 and not 5 because the ZipFile class is only available from .NET 4.5, and there's no guarantee that the OP uses .NET 4.5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900