|
-
Nov 11th, 2006, 10:07 AM
#1
Thread Starter
Member
[RESOLVED] ICSharpCode.SharpZipLib.Zip + zipping files and folders
I am trying to create a zip file that will contain both folders and files from different directories. I can create a zip file with just folders, or a zip with just files. But not both of them. To do the folder you have to use the FastZip. To do the files I use ZipOutputStream. Here is what I have now.
ZipOutputStream s = new ZipOutputStream(File.Create(strfullPath));
foreach (object fileName in lbxFiles.Items)
{
strTempPath = (string)fileName;
strTempPath=strTempPath.Remove(0,strTempPath.LastIndexOf("\\") + 1);
if (!Path.HasExtension(strTempPath))
{
FastZip sz = new FastZip();
sz.CreateZip("F:\\Testing.zip", "F:\\BackUp", true, "");
ZipEntry entry1 = new ZipEntry("F:\\Testing.zip");
s.PutNextEntry(entry1);
}
else
{
FileStream fs = File.OpenRead(strTempPath);
if (password != String.Empty) s.Password = password;
strTempPath = Path.GetFileName(strTempPath);
ZipEntry entry = new ZipEntry(strTempPath);
fs.Close();
s.PutNextEntry(entry);
}
If anyone has any ideas how I can get both files and folders into the same zip file I would appreciate it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|