0
我使用的是asp.net 4.0框架,我從我的頁面生成pdf文件並將這些pdf文件存儲在我的應用程序中的文件夾中。現在應用程序的大小變得太大,所以我想壓縮該pdf文件的文件夾並下載該文件夾。請建議我如何在c#中壓縮/解壓縮文件夾。壓縮的datavolume如何在asp.net框架4.0中壓縮/解壓縮文件夾
我使用的是asp.net 4.0框架,我從我的頁面生成pdf文件並將這些pdf文件存儲在我的應用程序中的文件夾中。現在應用程序的大小變得太大,所以我想壓縮該pdf文件的文件夾並下載該文件夾。請建議我如何在c#中壓縮/解壓縮文件夾。壓縮的datavolume如何在asp.net框架4.0中壓縮/解壓縮文件夾
一種方法是從生成該目錄的.zip文件夾:
using System;
using System.IO;
using System.IO.Compression;
namespace ConsoleApplication
{
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);
}
}
}
在這個例子中,你把你的.pdf文件夾,壓縮它,並提取其別的地方使用
CompressionLevel.Fastest, true
不知道你在問什麼。你想啓用文件夾壓縮來減少「應用程序的大小」?或者你想允許用戶下載你的應用程序生成的PDF文件的ZIP存檔? –
你試過了什麼?你得到了哪些錯誤?請查看[how-to-ask](http://stackoverflow.com/help/how-to-ask) – swe