2016-04-01 15 views
1

Kök klasörün altında 4 seviye bulunan bir klasörü sıkıştırmaya çalışıyorum, klasörü ziplayabiliyorum ama kökü içeriyor klasörleri de.Kök dizinleri asp.net cip ziplediğinizde nasıl engellenir C#

 using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile()) 
      { 

    zip.AddSelectedFiles("*",filepath,string.empty,false); 
    zip.Save(HttpContext.Current.Response.OutputStream); 
      } 

İhtiyacım, yalnızca klasör yapısının tamamını değil, bu dosya dosyasını sıkıştırmaktır.

Herhangi bir yardım için teşekkür ederiz.

cevap

2

bu örneği takip edin:

using (ZipFile zip = new ZipFile()) 
{ 
    // files in the filesystem like MyDocuments\ProjectX\File1.txt, will be 
    // stored in the zip archive as backup\File1.txt 
    zip.AddDirectory(@"MyDocuments\ProjectX", "backup"); 

    // files in the filesystem like MyMusic\Santana\OyeComoVa.mp3, will be 
    // stored in the zip archive as tunes\Santana\OyeComoVa.mp3 
    zip.AddDirectory("MyMusic", "tunes"); 

    // The Readme.txt file in the filesystem will be stored in the zip 
    // archive as documents\Readme.txt 
    zip.AddDirectory("Readme.txt", "documents"); 

    zip.Comment = "This zip was created at " + DateTime.Now.ToString("G"); 
    zip.Save(ZipFileToCreate); 
} 

Referans: http://dotnetzip.herobo.com/DNZHelp/Index.html

+0

sayesinde, işe yaradı. –