How to Unzip all .Zip file from Folder using C# 4.0 and without using any OpenSource Dll?

前端 未结 6 1448
礼貌的吻别
礼貌的吻别 2020-12-09 03:02

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 .Ne

6条回答
  •  死守一世寂寞
    2020-12-09 04:04

    In .net 4.0 Deflate and GZip cannot handle Zip files, but you can use shell function for Unzipping files.

    public FolderItems Extract()
    {
     var shell = new Shell();
     var sf = shell.NameSpace(_zipFile.Path);
     return sf.Items();
    }
    

    When extract Function is called you can save the returned folderItems by

        FolderItems Fits = Extract();
        foreach( var s in Fits)
        {
           shell.Namespace("TargetFolder").copyhere(s); 
    
        }
    

提交回复
热议问题