1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.IO;
  5. using Microsoft.Win32;
  6. using System.Diagnostics;
  7. using System.Web;
  8. public class Winrar
  9. {
  10. /// <summary>
  11. /// 是否安装了Winrar
  12. /// </summary>
  13. /// <returns></returns>
  14. static public bool Exists()
  15. {
  16. RegistryKey the_Reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE/Microsoft/Windows/CurrentVersion/App Paths/WinRAR.exe");
  17. return !string.IsNullOrEmpty(the_Reg.GetValue("").ToString());
  18. }
  19. /// <summary>
  20. /// 打包成Rar
  21. /// </summary>
  22. /// <param name="patch"></param>
  23. /// <param name="rarPatch"></param>
  24. /// <param name="rarName"></param>
  25. public string CompressRAR(string patch, string rarPatch, string rarName)
  26. {
  27. string the_rar;
  28. RegistryKey the_Reg;
  29. object the_Obj;
  30. string the_Info;
  31. ProcessStartInfo the_StartInfo;
  32. Process the_Process;
  33. try
  34. {
  35. the_Reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE/Microsoft/Windows/CurrentVersion/App Paths/WinRAR.exe");
  36. the_Obj = the_Reg.GetValue("");
  37. the_rar = the_Obj.ToString();
  38. the_Reg.Close();
  39. the_rar = the_rar.Substring(1, the_rar.Length - 7);
  40. Directory.CreateDirectory(patch);
  41. //命令参数
  42. //the_Info = " a    " + rarName + "  " + @"C:Test?70821.txt"; //文件压缩
  43. the_Info = " a    " + rarName + "  " + patch + "  -r"; ;
  44. the_StartInfo = new ProcessStartInfo();
  45. the_StartInfo.FileName = the_rar;
  46. the_StartInfo.Arguments = the_Info;
  47. the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
  48. //打包文件存放目录
  49. the_StartInfo.WorkingDirectory = rarPatch;
  50. the_Process = new Process();
  51. the_Process.StartInfo = the_StartInfo;
  52. the_Process.Start();
  53. the_Process.WaitForExit();
  54. the_Process.Close();
  55. }
  56. catch (Exception ex)
  57. {
  58. return ex.Message;
  59. }
  60. return string.Empty;
  61. }
  62. /// <summary>
  63. /// 解压
  64. /// </summary>
  65. /// <param name="unRarPatch"></param>
  66. /// <param name="rarPatch"></param>
  67. /// <param name="rarName"></param>
  68. /// <returns></returns>
  69. public string unCompressRAR(string unRarPatch, string rarPatch, string rarName)
  70. {
  71. string the_rar;
  72. RegistryKey the_Reg;
  73. object the_Obj;
  74. string the_Info;
  75. try
  76. {
  77. the_Reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE/Microsoft/Windows/CurrentVersion/App Paths/WinRAR.exe");
  78. the_Obj = the_Reg.GetValue("");
  79. the_rar = the_Obj.ToString();
  80. the_Reg.Close();
  81. //the_rar = the_rar.Substring(1, the_rar.Length - 7);
  82. if (Directory.Exists(unRarPatch) == false)
  83. {
  84. Directory.CreateDirectory(unRarPatch);
  85. }
  86. the_Info = "x /"" + rarName + "/" /"" + unRarPatch + "/" -y";
  87. ProcessStartInfo the_StartInfo = new ProcessStartInfo();
  88. the_StartInfo.FileName = the_rar;
  89. the_StartInfo.Arguments = the_Info;
  90. the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
  91. the_StartInfo.WorkingDirectory = rarPatch;//获取压缩包路径
  92. Process the_Process = new Process();
  93. the_Process.StartInfo = the_StartInfo;
  94. the_Process.Start();
  95. the_Process.WaitForExit();
  96. the_Process.Close();
  97. }
  98. catch (Exception ex)
  99. {
  100. return ex.Message;
  101. }
  102. return string.Empty;
  103. }
  104. }

asp.net 在线解压缩文件类的更多相关文章

  1. ASP.NET利用WINRar实现在线解压缩文件

    一.肯定是服务器必须装了winrar这个软件了. 二.创建Helper类,如下: using System; using System.Collections.Generic; using Syste ...

  2. asp利用winrar解压缩文件

    '当前文件夹路径 server.MapPath("./") '网站根目录 server.MapPath("/") Dim strZipFolder ' 待压缩的 ...

  3. ASP无惧上传类不能上传中文双引号文件及ASP函数InStr存在bug

    ASP无惧上传类不能上传中文双引号文件及ASP函数InStr存在bug 近日发现eWebEditor V2.8 asp 版本上传文件文件名不能包含中文双引号,发现eWebEditor使用ASP“无惧上 ...

  4. ASP.NET实现二维码 ASP.Net上传文件 SQL基础语法 C# 动态创建数据库三(MySQL) Net Core 实现谷歌翻译ApI 免费版 C#发布和调试WebService ajax调用WebService实现数据库操作 C# 实体类转json数据过滤掉字段为null的字段

    ASP.NET实现二维码 using System;using System.Collections.Generic;using System.Drawing;using System.Linq;us ...

  5. Unity3d通用工具类之解压缩文件

    今天,我们来写写c#是如何通过代码解压缩文件的. 在游戏的项目中呢,常常我们需要运用到解压缩的技术.比如,当游戏需要更新的时候,我们会从服务器中下载更新的压缩文件包. 这时候我们就需要解压文件,然后覆 ...

  6. ZIP解压缩文件的工具类【支持多级文件夹|全】

    ZIP解压缩文件的工具类[支持多级文件夹|全] 作者:Vashon 网上有非常多的加压缩演示样例代码.可是都仅仅是支持一级文件夹的操作.假设存在多级文件夹的话就不行了. 本解压缩工具类经过多次检查及重 ...

  7. ZIP解压缩文件的工具类【支持多级目录|全】

    ZIP解压缩文件的工具类[支持多级目录|全] 作者:Vashon 网上有很多的加压缩示例代码,但是都只是支持一级目录的操作,如果存在多级目录的话就不行了.本解压缩工具类经过多次检查及重构,最终分享给大 ...

  8. asp.net web开发——文件夹的上传和下载

    ASP.NET上传文件用FileUpLoad就可以,但是对文件夹的操作却不能用FileUpLoad来实现. 下面这个示例便是使用ASP.NET来实现上传文件夹并对文件夹进行压缩以及解压. ASP.NE ...

  9. asp.net之大文件断点续传

    ASP.NET上传文件用FileUpLoad就可以,但是对文件夹的操作却不能用FileUpLoad来实现. 下面这个示例便是使用ASP.NET来实现上传文件夹并对文件夹进行压缩以及解压. ASP.NE ...

随机推荐

  1. Linux C Socket编程原理及简单实例

    部分转自:http://goodcandle.cnblogs.com/archive/2005/12/10/294652.aspx 1.   什么是TCP/IP.UDP? 2.   Socket在哪里 ...

  2. IOS学习笔记02---语言发展概述,计算机语言简介.

    IOS学习笔记02---语言发展概述,计算机语言简介. ------------------------------------------------------------------------ ...

  3. go语言基础之切片做函数参数

    1.切片做函数参数 (备注:用了冒泡排序) 示例: package main //必须有个main包 import "fmt" import "math/rand&quo ...

  4. Same Tree leetcode java

    题目: Given two binary trees, write a function to check if they are equal or not. Two binary trees are ...

  5. shell more less cat

    cat 连续显示.查看文件内容 more 分页查看文件内容 less 分页可控制查看文件内容 通俗点说: cat一次性把文件内容全部显示出来,管你看不看得清,显示完了cat命令就返回了,不能进行交互式 ...

  6. sed 常用的命令

    n: 读取一行,执行n,把当前行打印到标准输出,再读取一行,覆盖当前行,然后对模式空间执行一组模式/行为.N:读取一行,执行N,再读取一行,现在模式空间有两行内容,执行一组模式/行为.如下:[root ...

  7. Ubuntu下配置jdk及maven等方法

    从/etc/profile文件代码得知系统启动会把/etc/profile.d目录下面所有的.sh文件进行加载,如果在其中新建.sh文件用来设立环境变量等,系统启动后也会加载到它们.另外一种方法就是修 ...

  8. ZH奶酪:【数据结构与算法】并查集基础

    1.介绍 并查集是一种树型数据结构,用于处理一些不相交集合的合并问题. 并查集主要操作有: (1)合并两个不相交集合: (2)判断两个元素是否属于同一个集合: (3)路径压缩: 2.常用操作 用fat ...

  9. php之快速入门学习-4(数据类型)

    PHP 5 数据类型 String(字符串), Integer(整型), Float(浮点型), Boolean(布尔型), Array(数组), Object(对象), NULL(空值). PHP ...

  10. Java中执行存储过程和函数(web基础学习笔记十四)

    一.概述 如果想要执行存储过程,我们应该使用 CallableStatement 接口. CallableStatement 接口继承自PreparedStatement 接口.所以CallableS ...