如何使用C#4.0和不使用任何开放源DLL来从解压缩文件夹中所有的.zip文件? [英] How to Unzip all .Zip file from Folder using C# 4.0 and without using any OpenSource Dll?

查看:610
本文介绍了如何使用C#4.0和不使用任何开放源DLL来从解压缩文件夹中所有的.zip文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含 .ZIP文件的文件夹即可。现在,我想解压缩ZIP文件来使用C#特定的文件夹,而无需使用任何外部组件或.NET Framework 4.5。

I have a folder containing .ZIP files. Now, I want to Extract the ZIP Files to specific folders using C#, but without using any external assembly or the .Net Framework 4.5.

我已搜查,但没有发现拆包使用框架4.0或以下* .zip文件的任何解决方案。

I have searched, but not found any solution for unpacking *.zip files using Framework 4.0 or below.

我试过GZipStream,但它仅支持.gz的,而不是.zip文件。

I tried GZipStream, but it only supports .gz and not .zip files.

推荐答案

下面是例如,从的 MSDN System.IO.Compression.ZipFile 只是为提出:

Here is example from msdn. System.IO.Compression.ZipFile is made just for that:

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及以上。

sorry, I missed that you're interests in .NET 4.0 and below. Required .NET framework 4.5 and above.

这篇关于如何使用C#4.0和不使用任何开放源DLL来从解压缩文件夹中所有的.zip文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆