ابتدا name space زير را اضافه كنيد:
using ICSharpCode.SharpZipLib.Zip;
سپس در كد دكمه اي كه مي خواهيد zip كند ، كد زير را وارد نماييد:
string zipFileStoragePath = "C:\\";
string zipFileName = "test.zip";
string fileToCompress = "C:\\Sunset.jpg";
ZipFile z = ZipFile.Create(zipFileStoragePath + zipFileName);
//initialize the file so that it can accept updates
z.BeginUpdate();
//add the file to the zip file
z.Add(fileToCompress);
//commit the update once we are done
z.CommitUpdate();
//close the file
z.Close();
اگر نتوانستيد namespase را اضافه كنيد ، به refrence هاي پروژه ،از مسير زير ، dll مربوطه را اضافه كنيد: