I am using Ionic.zip to zip up the files.
You consider there are 2 files in c:\\img\\a.txt and b.txt. When zip up these files as following
using (ZipFile zip = new ZipFile())
{
zip.AddItem(@"F:\imp\a.txt");
zip.AddItem(@"F:\imp\b.txt");
zip.AddItem(@"F:\imp\lookup.ini");
zip.AddItem(@"F:\imp\lookups.mdb");
zip.Save("Lookups.zip");
}
It is creating lookups.zip file correctly. But the problem is content of zip file is...
there is one directory named as imp and it is contains those 2files.
But i do not need of the directory entry only i need files which i added.
Please help me.
As shown in the documentation , use the overload which accepts two strings - one for the directory in the zip file:
using (ZipFile zip = new ZipFile())
{
zip.AddItem(@"F:\imp\a.txt", "");
zip.AddItem(@"F:\imp\b.txt", "");
zip.AddItem(@"F:\imp\lookup.ini", "");
zip.AddItem(@"F:\imp\lookups.mdb", "");
zip.Save("Lookups.zip");
}
(That looks like 4 files to me, not 2, and in imp rather than img... but never mind.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.