2016-06-15 16 views
1

私はホームと呼ばれるルートフォルダを持つフォルダ構造を持っています。 ホームフォルダには3つのサブフォルダと5つのファイルがあります。 ionic.zipを使用したときこのホームフォルダのすべてのファイルを圧縮することができます。しかし、私は同じフォルダ構造を維持することができません。asp.netで圧縮中にサブフォルダを含めるには?

string[] filePaths = Directory.GetFiles("filepath","*",SearchOption.AllDirectories); 
if (filePaths.Length > 0) 
{ 
    foreach (string fileURl in filePaths) 
    { 
     zip.AddFile(fileURl, "VisaFiles");    
    } 
} 

答えて

0

あなたが参考文献にSystem.IO.Compression.FileSystem.dllを含める必要がありますZIPファイルクラスSystem.IO.Compression.FileSystem

class Program 
{ 
    static void Main(string[] args) 
    { 
     string startPath = @"c:\example\start"; 
     string zipPath = @"c:\example\result.zip"; 
     string extractPath = @"c:\example\extract"; 

     ZipFile.CreateFromDirectory(startPath, zipPath, CompressionLevel.Fastest,true); 

     ZipFile.ExtractToDirectory(zipPath, extractPath); 
    } 
} 

を使用することができます。

+0

@ Abid-私のローカルマシンにこのファイルをダウンロードする必要があるので、どのように宛先のパスを与えることです。ダウンロードをクリックすると、圧縮されたフォルダが表示されます。 –

関連する問題