I want Selected folder path only stored convert file in C#
My Source Code is Below
using (ZipFile zip = new ZipFile()) { zip.AlternateEncodingUsage = ZipOption.AsNecessary; zip.AddDirectoryByName("Files"); foreach (GridViewRow row in GridView1.Rows) { if ((row.FindControl("chkSelect") as CheckBox).Checked) { string filePath = (row.FindControl("lblFilePath") as Label).Text; zip.AddFile(filePath, "Files.zip"); } } Response.Clear(); Response.BufferOutput = false; string zipName = String.Format("Zip_{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss")); Response.ContentType = "application/zip"; Response.AddHeader("content-disposition", "attachment; filename=" + zipName); zip.Save(Response.OutputStream); Response.End(); }
How to stored selected Folder in this above source code.
Example:
Convert zip file stored in this path:E:\convertZibsourcecode\ZIPFILE\zipa
Thanks
Sanjay KumarPosted Dec 27, 2014, 2:57 AM
try this
// This Code used Create Zip And ZipArchive Compression File
private void btnZipArchiveCompression_Click(object sender, EventArgs e)
{
string startPath = @"C:\sxs";
string zipPath = @"C:\Zips\result.zip";
//ZipFile.CreateFromDirectory(startPath, zipPath);
ZipFile.CreateFromDirectory(startPath, zipPath, CompressionLevel.Fastest, true);
MessageBox.Show("Zip file Create Successfully!! ");
}
// This Code used Extract Zip and ZipArchive DeCompression File
private void btnZipArchiveDeCompress_Click(object sender, EventArgs e)
{
string zipPath = @"C:\Zips\result.zip";
string ExtractPath = @"C:\Zips\extract";
ZipFile.ExtractToDirectory(zipPath, ExtractPath);
MessageBox.Show("Zip file Extract Successfully!! ");
}
http://www.c-sharpcorner.com/UploadFile/47548d/zip-archives-in-C-Sharp/