我有一个包含.ZIP 文件 的文件夹。现在,我想使用 C# 将 ZIP 文件解压缩到特定文件夹,但不使用任何外部程序集或 .Net Framework 4.5。
我搜索过,但没有找到任何使用 Framework 4.0 或以下版本解压 *.zip 文件的解决方案。
我试过 GZipStream,但它只支持 .gz 而不是 .zip 文件。
最佳答案
这是来自 msdn 的示例. System.IO.Compression.ZipFile
就是为此而生的:
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);
ZipFile.ExtractToDirectory(zipPath, extractPath);
}
}
}
编辑:抱歉,我没有注意到您对 .NET 4.0 及更低版本感兴趣。 需要 .NET Framework 4.5 及更高版本。
关于c# - 如何在不使用任何 OpenSource Dll 的情况下使用 C# 4.0 从文件夹中解压所有 .Zip 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16052877/