Skip to content
Loading
How to Extract and Save a Zipped Folder in My Local
c#
  1. protected void btnUpload_Click(object sender, EventArgs e)  
  2. {  
  3. if (fileUpload1.HasFile)  
  4. {  
  5. string filename = Path.GetFileName(fileUpload1.PostedFile.FileName);  
  6. string path = Server.MapPath("~/Zip/SampleFiles/" + filename);  
  7. string path1 = Server.MapPath("~/Zip/ExtractFiles/" + filename);  
  8. fileUpload1.SaveAs(path);  
  9. ExtractZipFile(path, path1);  
  10. if ((System.IO.File.Exists(path)))  
  11. {  
  12. System.IO.File.Delete(path);  
  13. }  
  14. lbltxt.Text = "File Uploaded Successfully";  
  15. }  
  16. }  
  17. private void ExtractZipFile(string zipFileLocation, string destination)  
  18. {  
  19. using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile(zipFileLocation))  
  20. {  
  21. zip.ExtractAll(destination); //zip.Save(destination);  
  22. }  
  23. }  
the above code is working exactly as well as live server
0
  • Logesh Palani
    Give the correct zip and unzip file location and permission to access this files
    0
  • Paul Rajs
    thanks a lot mr.Lokesh palani , for your valuable reply . but there is showing some error in Copy To 
    originalFileStream.CopyTo(compressionStream); line and  
    decompressionStream.CopyTo(decompressedFileStream); line bro , how can i fix this error bro  
    0