You could do something like:
private void button21_Click_1(object sender, EventArgs e)
{
// Note: Add a ref to the Com dll 'Microsoft Shell Controls And
Automation' in your project.
// Creates a new zip container and adds directory to it.
string zipFile = @"c:\myzip.zip";
if (!System.IO.File.Exists(zipFile))
System.IO.File.Delete(zipFile);
using(FileStream fs = new FileStream(zipFile, FileMode.Create,
FileAccess.Write))
{
byte[] emptyzip = new byte[] { 80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
fs.Write(emptyzip, 0, emptyzip.Length);
}
//Copy a folder and all its contents into zip file.
Shell32.ShellClass sc = new Shell32.ShellClass();
Shell32.Folder SrcFlder = sc.NameSpace(@"C:\temp\sampleapp");
Shell32.Folder DestFlder = sc.NameSpace(zipFile);
Shell32.FolderItems items = SrcFlder.Items();
DestFlder.CopyHere(items, 20);
Console.WriteLine("Done.");
}

Signature
William Stacey [MVP]
|I have a bunch of files I need to put into Compressed (zipped) Folder,
| MyFiles.zip file, similarly to what Windows XP does when you send files to
[quoted text clipped - 6 lines]
|
| Thanks,
Amelyan - 08 Mar 2006 22:31 GMT
Hi William,
I created a new project and added your code to main function. I also added
shell32.dll from c:\windows\System32 folder. I provided c:\temp as my
source folder that contains a bunch of files and folders.
However, when I run the program, it creates a myzip.zip that is 24bytes in
size, and when I open it, it is blank. Is there anything that I missed?
Thanks,
> You could do something like:
>
[quoted text clipped - 56 lines]
> |
> | Thanks,