c rar解壓大小 C 解壓 壓縮RAR檔案

2021-10-13 08:43:40 字數 4643 閱讀 7262

using system;

using system.collections.generic;

using system.text;

using system.io;

using microsoft.win32;

using system.diagnostics;

namespace uni.unicustoms

public class clswinrar

/// 是否安裝了winrar

static public bool exists()

registrykey the_reg =

registry.localmachine.opensubkey(

return !string.isnullorempty(the_reg.getvalue("").tostring());

/// 打包成rar

public void compressrar(string patch, 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.localmachine.opensubkey(

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);

//命令引數

//the_info = " a    " + rarname + " " + @"c:test?70821.txt"; //檔案壓縮

the_info = " a    " + rarname + " " + patch + " -r"; ;

the_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_process.waitforexit();

the_process.close();

catch (exception ex)

throw ex;

/// 解壓

public string uncompressrar(string unrarpatch, string rarpatch, string rarname)

string the_rar;

registrykey the_reg;

object the_obj;

string the_info;

trythe_reg =

registry.localmachine.opensubkey(

the_obj = the_reg.getvalue("");

the_rar = the_obj.tostring();

the_reg.close();

//the_rar = the_rar.substring(1, the_rar.length - 7);

if (directory.exists(unrarpatch) == false)

directory.createdirectory(unrarpatch);

the_info = "x " + rarname + " " + unrarpatch + " -y";

processstartinfo the_startinfo = new processstartinfo();

the_startinfo.filename = the_rar;

the_startinfo.arguments = the_info;

the_startinfo.windowstyle = processwindowstyle.hidden;

the_startinfo.workingdirectory = rarpatch;//獲取壓縮包路徑

process the_process = new process();

the_process.startinfo = the_startinfo;

the_process.start();

the_process.waitforexit();

the_process.close();

catch (exception ex)

throw ex;

return unrarpatch;

rar引數:

一、壓縮命令

1、將temp.txt壓縮為temp.rarrar a temp.rar temp.txt

2、將當前目錄下所有檔案壓縮到temp.rarrar a temp.rar *.*

3、將當前目錄下所有檔案及其所有子目錄壓縮到temp.rarrar a temp.rar *.* -r

4、將當前目錄下所有檔案及其所有子目錄壓縮到temp.rar,並加上密碼123rar a temp.rar *.* -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及其子目錄的檔案內容

wzzip test.zip test -r -p

winrar a test.rar test -r

刪除壓縮包中的*.txt檔案

wzzip test.zip *.txt -d

winrar d test.rar *.txt

重新整理壓縮包中的檔案,即新增已經存在於壓縮包中但更新的檔案

wzzip test.zip test -f

winrar f test.rar test

更新壓縮包中的檔案,即新增已經存在於壓縮包中但更新的檔案以及新檔案

wzzip test.zip test -u

winrar u test.rar test

移動檔案到壓縮包,即新增檔案到壓縮包後再刪除被壓縮的檔案

wzzip test.zip -r -p -m

winrar m test.rar test -r

新增全部 *.exe 檔案到壓縮檔案,但排除有 a或b

開頭名稱的檔案

wzzip test *.exe -xf*.* -xb*.*

winrar a test *.exe -xf*.* -xb*.*

加密碼進行壓縮

wzzip test.zip test

-s123。注意密碼是大小寫敏感的。在圖形介面下開啟帶密碼的壓縮檔案,會看到+號標記(附圖1)。

winrar a test.rar test -p123

-r。注意密碼是大小寫敏感的。在圖形介面下開啟帶密碼的壓縮檔案,會看到*號標記(附圖2)。

按名字排序、以簡要方式列表顯示壓縮包檔案

wzzip test.zip -vbn

rar l test.rar

鎖定壓縮包,即防止未來對壓縮包的任何修改

無對應命令

winrar k test.rar

建立360kb大小的分卷壓縮包

無對應命令

winrar a -v360 test

帶子目錄資訊解壓縮檔案

wzunzip test -d

winrar x test -r

不帶子目錄資訊解壓縮檔案

wzunzip test

winrar e test

解壓縮檔案到指定目錄,如果目錄不存在,自動建立

wzunzip test newfolder

winrar x test newfolder

解壓縮檔案並確認覆蓋檔案

wzunzip test -y

winrar x test -y

解壓縮特定檔案

wzunzip test *.txt

winrar x test *.txt

解壓縮現有檔案的更新檔案

wzunzip test -f

winrar x test -f

解壓縮現有檔案的更新檔案及新檔案

wzunzip test -n

winrar x test -u

批量解壓縮檔案

wzunzip *.zip

winrar e *.rar

c rar解壓大小 C 解壓 壓縮RAR檔案

using system using system.collections.generic using system.text using system.io using microsoft.win32 using system.diagnostics public class winrarhelp...

c rar解壓大小 C 壓縮 解壓縮

1 2 壓縮檔案 fnamearry 為客戶端傳回來的檔案列表 檔名陣列,壓縮包的名稱strzipname3 4 檔名陣列 5 壓縮包的名稱 6 public void zipfile string fnamearry stringstrzipname 7 19 20 u.finish 結束壓縮 2...

Linux解壓 壓縮

linux下自帶了乙個unzip的程式可以解壓縮檔案,解壓命令是 unzip filename.zip 同樣也提供了乙個zip程式壓縮zip檔案,命令是 zip filename.zip files 會將files壓縮到filename.zip 另外看看你的檔案的字尾名,不同的字尾的檔案解壓和壓縮的...