Click here to Skip to main content
15,900,387 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi All,

I want to zip a single file and save it in that folder only...But the container folder of that file is also getting zipped..Example: trying to zip a file with path D:\fol1\fol2\file.xlsx gives a zipped folder containing fol1\fol2\file.xlsx...But the size is getting compressed..here is my code...

VB
Imports Ionic.Zip
Using zip As Ionic.Zip.ZipFile = New Ionic.Zip.ZipFile
zip.AddFile("D:\SA\Updates\results\UPDATED_DUMP.xlsx")
zip.Save("D:\SA\Updates\results\UPDATED_DUMP.zip")
End Using


Am I doing anything wrong??

Thanks for help...
Posted
Comments
Sergey Alexandrovich Kryukov 2-Jun-14 10:14am    
First of all, please stop posting your fake "answers". They are not answers at all. This is considered as abuse. Instead of posting answers like "I solved it" or "Thank you", use comments and/or "Improve questions".
—SA

Check online documentation: ZipFile class[^]
 
Share this answer
 
try below
VB
Imports Ionic.Zip
Using zip As Ionic.Zip.ZipFile = New Ionic.Zip.ZipFile
zip.AddFile("D:\SA\Updates\results\UPDATED_DUMP.xlsx", "")
zip.Save("D:\SA\Updates\results\UPDATED_DUMP.zip")
End Using

reference:http://stackoverflow.com/questions/4125607/dotnetzip-add-files-without-creating-folders[^]
 
Share this answer
 
Comments
planetz 3-Jun-14 3:41am    
Thank you so much!!! It worked...
DamithSL 3-Jun-14 3:54am    
You are welcome!

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