c#解壓zip檔案

來源:互聯網
上載者:User

1.解壓方法 轉載自http://www.cnblogs.com/hiber/archive/2007/10/17/927795.html

"C#解壓.zip檔案,網上一搜一大堆方法,有使用System.IO.Compression.GZipStream的,有使用J#庫函數的,也有仿Java自己寫庫函數的,但好多都不大好使,最終發現還是系統函數System.Shell.Folder.copyHere(oItem [intOptions])最為好使。具體方法如下:

1. 添加引用 Shell32.dll,可以在Windows\system32中找到它。
2. 添加方法,搞定。

static void UnZip(string zipFile,string destFolder)
            {
                        Shell32.ShellClass sc = new Shell32.ShellClass();
                        Shell32.Folder SrcFolder = sc.NameSpace(zipFile);
                        Shell32.Folder DestFolder = sc.NameSpace(destFolder);
                        Shell32.FolderItems items = SrcFolder.Items();
                        DestFolder.CopyHere(items, 20);
            }

(這裡只需注意一點,destFolder必須是事先存在的 folder,此方法不會自動建立folder)

DestFolder.CopyHere(items, 20)中20的其實是一個intOptions flags (4|16),4指不要顯示處理視窗,16指如果處理視窗顯示的話就選擇"yes to all"。關於具體的intOptions描述,可以到http://msdn2.microsoft.com/en-us/library/ms723207.aspx中查看。"

 

2,遇到問題"VS2010中,無法嵌入互操作類型“……”,請改用適用的介面的解決方案" 解決轉載自http://www.cnblogs.com/ITGIS/articles/1797417.html

  "最近開始使用VS2010,在引用COM組件的時候,出現了無法嵌入互操作類型“……”,請改用適用的介面的錯誤提示。查閱資料,找到解決方案,記錄如下:

選中項目中引入的dll,滑鼠右鍵,選擇屬性,把“嵌入互操作類型”設定為False。"

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.