.NET 프레임워크 4.5 이상부터는 따로 압축과 관련한 클래스가 존재하지만 4.0 이하에서는 존재하지 않는다.

아래는 윈도우의 Shell32를 이용하여 해결하는 방법.

 

Visual Studio를 사용하는 것을 기준으로, 참조에서 [프로젝트] - [참조]를 오른쪽 클릭하여 '참조 추가...'를 통해 참조 관리자 창을 열고 COM 항목을 열어 Microsoft Shell Controls And Automation 을 찾아서 참조를 추가한다.

그리고 아래와 같은 코드를 넣어서 사용한다.

private static void UnZip(string zipFile, string folderPath)
{
    if (!File.Exists(zipFile))
        throw new FileNotFoundException();

    if (!Directory.Exists(folderPath))
        Directory.CreateDirectory(folderPath);

    Shell32.Shell objShell = new Shell32.Shell();
    Shell32.Folder destinationFolder = objShell.NameSpace(folderPath);
    Shell32.Folder sourceFile = objShell.NameSpace(zipFile);

    foreach (var file in sourceFile.Items()) {
        destinationFolder.CopyHere(file, 4 | 16);
    }
}