



下載本文檔
版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、C#調(diào)用 WINRAR 實現(xiàn)壓縮與解壓 .txt 性格本身沒有好壞,樂觀和悲觀對這個世界都有貢獻,前 者發(fā) 明 了 飛 機 , 后 者 發(fā) 明 了 降 落 傘 。 public void RARsave(string patch,stringrarPatch,string rarName)String the_rar;RegistryKey the_Reg;Object the_Obj;String the_Info;ProcessStartInfo the_StartInfo;Process the_Process;trythe_Reg=Registry.ClassesRoot.OpenSu
2、bKey(ApplicationsWinRAR.exeShellOpenCommand);the_Obj = the_Reg.GetValue();the_rar = the_Obj.ToString();the_Reg.Close();the_rar = the_rar.Substring(1, the_rar.Length - 7);Directory.CreateDirectory(patch);/命令參數(shù)/the_Info = a + rarName + + C:Test?70821.txt; /文件壓縮the_Info = a + rarName + + patch + -r; ;t
3、he_StartInfo = new ProcessStartInfo();the_StartInfo.FileName = the_rar;the_StartInfo.Arguments = the_Info;the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;/打包文件存放目錄the_StartInfo.WorkingDirectory = rarPatch;the_Process = new Process();the_Process.StartInfo = the_StartInfo;the_Process.Start();the
4、_Process.WaitForExit();the_Process.Close();catch (Exception ex)throw ex;public string unRAR(string unRarPatch,string rarPatch,string rarName)String the_rar;RegistryKey the_Reg;Object the_Obj;String the_Info;ProcessStartInfo the_StartInfo;Process the_Process;trythe_Reg =Registry.ClassesRoot.OpenSubKe
5、y(ApplicationsWinRAR.exeShellOpenCommand);the_Obj = the_Reg.GetValue();the_rar = the_Obj.ToString();the_Reg.Close();the_rar = the_rar.Substring(1, the_rar.Length - 7);Directory.CreateDirectory(Server.MapPath(unRarPatch);the_Info= e+ rarName + + Server.MapPath(unRarPatch)+ -y;the_StartInfo = new Proc
6、essStartInfo();the_StartInfo.FileName = the_rar;the_StartInfo.Arguments = the_Info;the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;the_StartInfo.WorkingDirectory = Server.MapPath(rarPatch);/獲取壓縮包路徑the_Process = new Process();the_Process.StartInfo = the_StartInfo;the_Process.Start();the_Process
7、.WaitForExit();the_Process.Close();catch (Exception ex)throw ex;return Server.MapPath(unRarPatch);RAR 參數(shù):一、壓縮命令1、將 temp.txt壓縮為temp.rarrar a temp.rar temp.txt2、將當前目錄下所有文件壓縮到temp.rarrar a temp.rar *.*3、將當前目錄下所有文件及其所有子目錄壓縮到temp.rarrar a temp.rar *.* -r4、將當前目錄下所有文件及其所有子目錄壓縮到temp.rar,并加上密碼123rar a temp.r
8、ar*.* -r -p123二、解壓命令1、將 temp.rar解壓到c:temp目錄rar e temp.rar c:temprar e *.rar c:temp(支持批量操作 )2、將 temp.rar解壓到c:temp目錄,并且解壓后的目錄結構和temp.rar中的目錄結構一壓縮目錄 test及其子目錄的文件內(nèi)容Wzzip test.zip test -r -PWINRAR A test.rar test -r刪除壓縮包中的*.txt文件Wzzip test.zip *.txt -dWinRAR d test.rar *.txt刷新壓縮包中的文件,即添加已經(jīng)存在于壓縮包中但更新的文件Wz
9、zip test.zip test -fWinrar f test.rar test更新壓縮包中的文件,即添加已經(jīng)存在于壓縮包中但更新的文件以及新文件Wzzip test.zip test -uWinrar u test.rar test移動文件到壓縮包,即添加文件到壓縮包后再刪除被壓縮的文件Wzzip test.zip -r -P -mWinrar m test.rar test -r添加全部*.exe開頭名稱的文件文件到壓縮文件,但排除有a 或bWzzip test *.exe -xf*.* -xb*.*WinRAR a test *.exe -xf*.* -xb*.*加密碼進行壓縮Wzz
10、ip test.zip test-s123 。注意密碼是大小寫敏感的。在圖形界面下打開帶密碼的壓縮文件,會看到 +號標記(附圖 1)。WINRAR A test.rar test -p123-r 。注意密碼是大小寫敏感的。在圖形界面下打開帶密碼的壓縮文件,會看到 * 號標記(附圖2)。按名字排序、以簡要方式列表顯示壓縮包文件Wzzip test.zip -vbnRar l test.rar鎖定壓縮包,即防止未來對壓縮包的任何修改無對應命令Winrar k test.rar創(chuàng)建 360kb 大小的分卷壓縮包無對應命令Winrar a -v360 test帶子目錄信息解壓縮文件Wzunzip test -dWinrar x test -r不帶子目錄信息解壓縮文件Wzunzip testWinrar e test解壓縮文件到指定目錄,如果目錄不存在,自動創(chuàng)建Wzunzip test newfolderWinrar x test newfolder解壓縮文件并確認覆蓋文件Wzunzip test -yWinrar x test -y解壓
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 遂寧職業(yè)學院《生物信息與智能醫(yī)學導論》2023-2024學年第二學期期末試卷
- 中級宏觀經(jīng)濟學(雙語)(山東聯(lián)盟)知到課后答案智慧樹章節(jié)測試答案2025年春山東財經(jīng)大學
- 中式面點制作工藝知到課后答案智慧樹章節(jié)測試答案2025年春青島酒店管理職業(yè)技術學院
- 中外兒童文學經(jīng)典閱讀與寫作知到課后答案智慧樹章節(jié)測試答案2025年春湖南師范大學
- 中醫(yī)藥基礎入門知到課后答案智慧樹章節(jié)測試答案2025年春內(nèi)江師范學院
- 天津工藝美術職業(yè)學院《影視節(jié)目錄制與傳播》2023-2024學年第二學期期末試卷
- 池州學院《電氣控制與可編程控制技術》2023-2024學年第二學期期末試卷
- 中國音樂學院《修建性詳細規(guī)劃制圖》2023-2024學年第二學期期末試卷
- 鄭州汽車工程職業(yè)學院《康復醫(yī)學概論》2023-2024學年第二學期期末試卷
- 上海電機學院《大學生就業(yè)與創(chuàng)業(yè)指導》2023-2024學年第一學期期末試卷
- 2025中國遠洋海運集團校園招聘1484人筆試參考題庫附帶答案詳解
- 2025年安徽商貿(mào)職業(yè)技術學院單招職業(yè)技能考試題庫一套
- 2025年皖西衛(wèi)生職業(yè)學院單招職業(yè)技能測試題庫審定版
- 2025年河南經(jīng)貿(mào)職業(yè)學院單招職業(yè)適應性測試題庫帶答案
- unctad -全球投資趨勢監(jiān)測 第 48 期 Global Investment Trends Monitor,No. 48
- 2025年浙江機電職業(yè)技術學院高職單招職業(yè)技能測試近5年??及鎱⒖碱}庫含答案解析
- GA/T 2145-2024法庭科學涉火案件物證檢驗實驗室建設技術規(guī)范
- 2025年聚焦全國兩會知識競賽題庫及答案(共100題)
- 2024智能網(wǎng)聯(lián)汽車零部件行業(yè)研究報告-2025-01-智能網(wǎng)聯(lián)
- 2025年中國融通資產(chǎn)管理集團限公司春季招聘(511人)高頻重點提升(共500題)附帶答案詳解
- 急性心肌梗死的急救與護理
評論
0/150
提交評論