c# rar解压大小_C#解压RAR压缩文件
C# RAR压缩或解压文件
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(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRAR.exe");
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;
try
{
the_Reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRAR.exe");
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;
try
{
the_Reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRAR.exe");
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
posted on
2010-03-09 12:30
vcool
阅读(632)
评论(0)
编辑
收藏
c# rar解压大小_C#解压RAR压缩文件相关推荐
- c# rar解压大小_C#解压缩Zip,Rar等压缩文件(详细说明)
其实这个东西网上已经有很多了 给出了一大把 当然我也是在网上找到得 只不过 说明不够详细 经过测试 给出详细的备注: 解压的给的很详细 压缩的基本也一样 只不过参数信息不一样罢了: 利用winra ...
- c# rar解压大小_C#利用WinRAR实现压缩和解压缩
usingSystem;usingMicrosoft.Win32;usingSystem.Diagnostics;usingSystem.IO;namespaceMSCL {/// ///压缩解压类/ ...
- 使用Java生成的ZIP压缩包解压时出现不可预料的压缩文件末端的解决方案
使用Java生成的ZIP压缩包解压时出现不可预料的压缩文件末端的解决方案 问题描述: 如下图所示,在解压Java程序生成的ZIP压缩包时出现不可预料的压缩文件末端, 问题分袖: 出现上面的情况,大概有 ...
- gzp解压命令 linux_Linux gzip命令:压缩文件或目录
gzip 是 Linux 系统中经常用来对文件进行压缩和解压缩的命令,通过此命令压缩得到的新文件,其扩展名通常标记为".gz". 再强调一下,gzip 命令只能用来压缩文件,不能压 ...
- linux看zip的目录结构,无需解压如何查看一个归档或压缩文件的内容
在本教程中,我们将学习如何在类 Unix 系统中查看一个归档或者压缩文件的内容而无需实际解压它.在深入之前,让我们先厘清归档和压缩文件的概念,它们之间有显著不同.归档是将多个文件或者目录归并到一个文件 ...
- Colab在线解压Google Driver上的zip压缩文件
今天才发现可以用Google的Colaboratory可以训练pytorch神经网络,真的太高兴了,这样就可以解决我渣渣的电脑没有GPU,无法训练大型神经网络的问题了. 但是由于需要上传本地训练数据, ...
- mac上好用的压缩_Mac上除了快压还有哪些好用的压缩文件
展开全部 一.keka Keka for Mac是一e69da5e6ba9062616964757a686964616f31333431366366款应用在Mac端的轻量级压缩解压工具,支持压缩:7z ...
- linux解压多个part rar,【linux】安装rar,并解压被压缩成多个rar的文件
rar 官网:http://www.rarsoft.com/download.htm 选择 RAR for linux (注意你的系统是32位还是64位) 1 安装命令: $ cd /roo ...
- linux常用解压和压缩文件的命令
linux常用解压和压缩文件的命令 .tar 解包:tar xvf FileName.tar 打包:tar cvf FileName.tar DirName (注:tar是打包,不是压缩!) ---- ...
最新文章
- ajax data参数没有值,ajax $.get的data参数无法传递
- 什么是生存分析(survival analysis)?
- 本周学习进度表及时间安排(2018-1-7~2018-1-13)
- VC++更改鼠标指针为系统预定义形状和自定义形状
- hp服务器如何ghost系统,惠普(HP)电脑安装不了GHOST系统的解决办法
- 如何配置java环境变量
- [C/C++]记录:使用sprintf_s时第二个参数不严格计算导致栈损坏
- 手机信号G、E、O、3G代表什么意思?
- python turtle画熊猫人_Python 使用turtle插件,画小猪佩奇
- 国产机GSM系列手机常见芯片方案介绍
- 安全跑路指南2013之乌云版
- Macbook鼠标调节外接显示器亮度 - Shades for Mac(屏幕亮度调节软件) V1.2 苹果电脑版
- python人狗大战游戏_6.5 人狗大战.py
- 蓝凌生态OA,重新定义中大型企业数字化办公
- 生物特征识别技术领跑者--墨奇科技 全面亮相2022身份识别技术大会
- matlab输出的图怎么设置网格背景图片,4.11Python数据处理篇之Matplotlib系列(十一)---图例,网格,背景的设置...
- 程序员如何创新?逆工程师思维
- 设计要用计算机吗,作为设计师 你需要这样的笔记本电脑
- Unable to negotiate with xx.xx port xx: no matching host key type found. Their offer: ssh-rsa....
- linux编译有线程的文件要加什么参数,Linux多线程实例,在编译中要加 -lpthread参数...
热门文章
- 朱光潜给青年的十二封信 之 谈读书
- 转自博客园:http://www.cnblogs.com/txw1958/p/wechat-tutorial.html
- 信贷业务全流程22个环节
- BGP进阶:BGP 综合实验一
- 如何测算BMI指数(Python)
- win10可用空间新建卷提示磁盘上没有足够的空间完成此操作如何解决
- win7系统安装telnet服务器,Win7系统下怎么安装Telnet服务【图文教程】
- 网络安全之交换技术篇
- 廖雪峰python教程阅读之条件判断
- PHP是专为后端,后端开发PHP入门必备