此方法适用于C盘windows文件夹中有WinRAR.exe文件

 /// 解压文件(不带密码) RAR压缩程序  返回解压出来的文件数量
/// </summary>
/// <param name="destPath">解压至目录</param>
/// <param name="rarfilePath">压缩文件路径</param>
public static int RARToFileEmail(string destPath, string rarfilePath)
{
try
{
//组合出需要shell的完整格式
string shellArguments = string.Format("x -o+ \"{0}\" \"{1}\\\"",
rarfilePath, destPath); //用Process调用
using (Process unrar = new Process())
{
unrar.StartInfo.FileName = "winrar.exe";
unrar.StartInfo.Arguments = shellArguments;
//隐藏rar本身的窗口
unrar.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
unrar.Start();
//等待解压完成
unrar.WaitForExit();
unrar.Close();
}
//统计解压后的目录和文件数
//string str=string.Format("解压完成,共解压出:{0}个目录,{1}个文件",
// di.GetDirectories().Length, di.GetFiles().Length);
//return str;
}
catch (Exception ex)
{
return 0;
}
DirectoryInfo di = new DirectoryInfo(destPath);
int dirfileCount = 0;
foreach (System.IO.DirectoryInfo dir in di.GetDirectories())
{
dirfileCount++;
}
foreach (System.IO.FileInfo item in di.GetFiles())
{
dirfileCount++;
}
return dirfileCount;
}

C# 解压RAR压缩文件的更多相关文章

  1. linux解压rar压缩文件

    服务器是阿里云的 centos 默认linux是没有安装解压rar,zip的软件的.而网上找到的yum install命令也没有用.而且这个rar并不是免费的,只有40天的试用期...真是坑啊 由于用 ...

  2. [转]Ubuntu Linux 安装 .7z 解压和压缩文件

    [转]Ubuntu Linux 安装 .7z 解压和压缩文件 http://blog.csdn.net/zqlovlg/article/details/8033456 安装方法: sudo apt-g ...

  3. 【VC++技术杂谈008】使用zlib解压zip压缩文件

    最近因为项目的需要,要对zip压缩文件进行批量解压.在网上查阅了相关的资料后,最终使用zlib开源库实现了该功能.本文将对zlib开源库进行简单介绍,并给出一个使用zlib开源库对zip压缩文件进行解 ...

  4. C#利用SharpZipLib解压或压缩文件夹实例操作

    最近要做一个项目涉及到C#中压缩与解压缩的问题的解决方法,大家分享. 这里主要解决文件夹包含文件夹的解压缩问题. )下载SharpZipLib.dll,在http://www.icsharpcode. ...

  5. C#解压或压缩文件夹

    这里主要解决文件夹包含文件夹的解压缩问题.1)下载SharpZipLib.dll,在http://www.icsharpcode.net/OpenSource /SharpZipLib/Downloa ...

  6. C# 解压zip压缩文件

    此方法需要在程序内引用ICSharpCode.SharpZipLib.dll 类库 /// <summary> /// 功能:解压zip格式的文件. /// </summary> ...

  7. [转]Ubuntu Linux 安装 .7z 解压和压缩文件

    原文网址:http://blog.csdn.net/zqlovlg/article/details/8033456 安装方法: sudo apt-get install p7zip-full 解压文件 ...

  8. C# 解压与压缩文件

    解压文件 ,引用 SharpZipLib.dll类库 方法一: public void UnGzipFile(string zipfilename) { //同压缩文件同级同名的非压缩文件路径 var ...

  9. ubuntu解压和压缩文件

    .tar 解包:tar xvf FileName.tar打包:tar cvf FileName.tar DirName(注:tar是打包,不是压缩!)———————————————.gz解压1:gun ...

随机推荐

  1. Android 开发问题集合

    1.屏幕横.竖切换 修改“AndroidManifest.xml”的android:screenOrientation 一般需要:landscape.portrait 2.修改应用名字 修改“Andr ...

  2. vim 支持 markdown 语法

    /************************************************************************* * vim 支持 markdown 语法 * 说明 ...

  3. Java [Leetcode 101]Symmetric Tree

    题目描述: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). ...

  4. poj 3211 Washing Clothes

    // 题意 :夫妻两洗衣服,衣服有m种颜色,每种颜色又有若干件,每件衣服洗完需要特定的时间,要求每种颜色放在一起洗,洗完才能洗其他衣服.最后问洗完需要的最少时间// 将衣服按颜色分类 然后求出每种颜色 ...

  5. [Papers]NSE, $u_3$, Lebesgue space [Kukavica-Ziane, Nonlinearity, 2006]

    $$\bex u_3\in L^p(0,T;L^q(\bbR^3)),\quad \frac{2}{p}+\frac{3}{q}=\frac{5}{8},\quad \frac{24}{5}<q ...

  6. 【Android】以BaseAdapter做适配器的ListView及其性能优化

    适配器的Java类 package com.app.adapter; import org.json.JSONArray; import org.json.JSONObject; import and ...

  7. How to enable DateTimePicker to use both date and time z

    Recently in one of my project I needed to have an option to display the DateTimePicker allowing user ...

  8. Handling HTTP 404 Error in ASP.NET Web API

            Introduction: Building modern HTTP/RESTful/RPC services has become very easy with the new AS ...

  9. 【JSONCpp】简介及demo

    一.JSON简介 JSON 一种轻量级的数据交换格式,易于阅读.编写.解析,全称为JavsScript ObjectNotation. JSON由两种基本结构组成 ①   名字/值 对的集合,可以理解 ...

  10. Flume OG 与 Flume NG 的区别

    1.Flume OG:Flume original generation 即Flume 0.9.x版本    Flume NG:Flume next generation ,即Flume 1.x版本 ...