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
c# rar解压大小_C#解压、压缩RAR文件相关推荐
- c# rar解压大小_C#解压RAR压缩文件
C# RAR压缩或解压文件 using System; using System.Collections.Generic; using System.Text; using System.IO; us ...
- c# rar解压大小_C#解压缩Zip,Rar等压缩文件(详细说明)
其实这个东西网上已经有很多了 给出了一大把 当然我也是在网上找到得 只不过 说明不够详细 经过测试 给出详细的备注: 解压的给的很详细 压缩的基本也一样 只不过参数信息不一样罢了: 利用winra ...
- c# rar解压大小_C#利用WinRAR实现压缩和解压缩
usingSystem;usingMicrosoft.Win32;usingSystem.Diagnostics;usingSystem.IO;namespaceMSCL {/// ///压缩解压类/ ...
- linux压缩到最小命令,Linux下压缩某个文件夹命令
tar -zcvf /home/xahot.tar.gz /xahot tar -zcvf 打包后生成的文件名全路径 要打包的目录 例子:把/xahot文件夹打包后生成一个/home/xahot.ta ...
- linux rar加压_如何在linux下解压缩rar格式的文件压缩包
######################################################### #老男孩笔记系列-如何在linux下解压缩rar格式的文件压缩包 #date:201 ...
- Linux系统rar格式怎么解压,如何在linux下解压缩rar格式的文件压缩包
这样方便解压,一般来说没有理由要用rar.关于 linux上unzip命令有空细讲, 本节讲下,如何让linux支持解压缩rar文件 一 .系统环境 1.1 系统环境 实验环境一: CentOS re ...
- Python 技术篇-用zipfile库进行zip文件的压缩与解压实例演示,python压缩本地文件夹为zip文件并保留目录结构
首先给大家演示下 zip 文件的解压方法. import zipfiledef zip_extract_to(path_zip, path_aim):'''作用:解压压缩包参数一:压缩包位置参数二:解 ...
- 如何压缩pdf文件的大小?四种方法值得收藏
如何压缩pdf文件的大小?实际上,压缩PDF文件的主要原因是为了减小文件的大小以便于存储.传输和分享.通常情况下,PDF文件包含大量的图像.文本和其他媒体元素,因此它们的文件大小可能会非常大.如果您需 ...
- c# rar解压大小_Linux压缩解压指令-bzip2、xz、compress、rar
前面已经进介绍过Linux中用到的归档程序tar,文件压缩解压程序gzip.zip,今天继续介绍另外四种常见的压缩程序bzip2.compress.xz.rar. 文件压缩 bzip2 bzip2采用 ...
- centos解压分卷rar_centos解压和压缩rar格式文件
在liunx下原本是不支持rar文件的,需要安装liunx下的winrar版本,操作如下 wget http://www.rarsoft.com/rar/rarlinux-4.0.1.tar.gz t ...
最新文章
- mongo在哪创建管理员_mongodb权限设置之添加管理员、普通用户的方法
- JMeter 下载安装教程
- 数据库兼容级别对数据备份还原的影响
- find查找所有php,linux中的find命令—查找文件名
- 新单词 part 4
- 模板 - 快速沃尔什变换
- 防御 | 阻止木马侵入(电脑设置)
- python数据挖掘学习笔记】十.Pandas、Matplotlib、PCA绘图实用代码补充
- 英雄联盟官宣IG冠军皮肤 彩蛋竟是王思聪吃热狗...
- poj 3177 Redundant Paths(tarjan边双连通)
- easyui onclickrow 中获取列名_获取Chrome浏览器历史浏览记录实例
- ssh无密码登录_3个简单步骤即可完成无密码SSH登录
- iOS开发之UIView常用的一些方法小记之setNeedsDisplay和setNeedsLayout
- 用图片搜索图片的几个好网站
- Mybatis源码分析(一) JDBC Mybatis 简介
- b站视频下载和字幕下载的方法
- 随机数生成器python_python安全开发军规之四:使用安全的随机数生成器
- 发送短信验证码时触发天级流控Premit:10
- 2021年中国服务进出口回顾:进出口总额持续快速增长,其中:知识密集型服务贸易占比提高[图]
- SpringBoot 实现 QQ邮箱注册和登录