asp.net 在线解压缩文件类
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.IO;
- using Microsoft.Win32;
- using System.Diagnostics;
- using System.Web;
- public class Winrar
- {
- /// <summary>
- /// 是否安装了Winrar
- /// </summary>
- /// <returns></returns>
- 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());
- }
- /// <summary>
- /// 打包成Rar
- /// </summary>
- /// <param name="patch"></param>
- /// <param name="rarPatch"></param>
- /// <param name="rarName"></param>
- public string 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)
- {
- return ex.Message;
- }
- return string.Empty;
- }
- /// <summary>
- /// 解压
- /// </summary>
- /// <param name="unRarPatch"></param>
- /// <param name="rarPatch"></param>
- /// <param name="rarName"></param>
- /// <returns></returns>
- 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)
- {
- return ex.Message;
- }
- return string.Empty;
- }
- }
asp.net 在线解压缩文件类的更多相关文章
- ASP.NET利用WINRar实现在线解压缩文件
一.肯定是服务器必须装了winrar这个软件了. 二.创建Helper类,如下: using System; using System.Collections.Generic; using Syste ...
- asp利用winrar解压缩文件
'当前文件夹路径 server.MapPath("./") '网站根目录 server.MapPath("/") Dim strZipFolder ' 待压缩的 ...
- ASP无惧上传类不能上传中文双引号文件及ASP函数InStr存在bug
ASP无惧上传类不能上传中文双引号文件及ASP函数InStr存在bug 近日发现eWebEditor V2.8 asp 版本上传文件文件名不能包含中文双引号,发现eWebEditor使用ASP“无惧上 ...
- 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 ...
- Unity3d通用工具类之解压缩文件
今天,我们来写写c#是如何通过代码解压缩文件的. 在游戏的项目中呢,常常我们需要运用到解压缩的技术.比如,当游戏需要更新的时候,我们会从服务器中下载更新的压缩文件包. 这时候我们就需要解压文件,然后覆 ...
- ZIP解压缩文件的工具类【支持多级文件夹|全】
ZIP解压缩文件的工具类[支持多级文件夹|全] 作者:Vashon 网上有非常多的加压缩演示样例代码.可是都仅仅是支持一级文件夹的操作.假设存在多级文件夹的话就不行了. 本解压缩工具类经过多次检查及重 ...
- ZIP解压缩文件的工具类【支持多级目录|全】
ZIP解压缩文件的工具类[支持多级目录|全] 作者:Vashon 网上有很多的加压缩示例代码,但是都只是支持一级目录的操作,如果存在多级目录的话就不行了.本解压缩工具类经过多次检查及重构,最终分享给大 ...
- asp.net web开发——文件夹的上传和下载
ASP.NET上传文件用FileUpLoad就可以,但是对文件夹的操作却不能用FileUpLoad来实现. 下面这个示例便是使用ASP.NET来实现上传文件夹并对文件夹进行压缩以及解压. ASP.NE ...
- asp.net之大文件断点续传
ASP.NET上传文件用FileUpLoad就可以,但是对文件夹的操作却不能用FileUpLoad来实现. 下面这个示例便是使用ASP.NET来实现上传文件夹并对文件夹进行压缩以及解压. ASP.NE ...
随机推荐
- Pascal VOC & COCO数据集介绍 & 转换
目录 Pascal VOC & COCO数据集介绍 Pascal VOC数据集介绍 1. JPEGImages 2. Annotations 3. ImageSets 4. Segmentat ...
- 通过小实例谈谈javascript的间隔调用和延时调用
用 setInterval方法可以以指定的间隔实现循环调用函数,直到clearInterval方法取消循环 用clearInterval方法取消循环时,必须将setInterval方法的调用赋值给一个 ...
- 修改一行SQL代码 性能提升了100倍
在PostgreSQL中修改了一行不明显的代码,把(ANY(ARRAY[...]) 改成 ANY(VALUES(...))),结果查询时间从20s变为0.2s.最初我们学习使用 EXPLAN ANAL ...
- 解析XML并将信息封装到对象中
[person.xml]要解析的内容 <?xml version="1.0" encoding="UTF-8"?> <students> ...
- spring boot常用注解使用小结
1.@RestController和@RequestMapping注解 4.0重要的一个新的改进是@RestController注解,它继承自@Controller注解. 4.0之前的版本,Sprin ...
- [置顶] 利用Global.asax的Application_Error实现错误记录,错误日志
利用Global.asax的Application_Error实现错误记录 错误日志 void Application_Error(object sender, EventArgs e) { // 在 ...
- Global and Local Coordinate Systems
ansys 中的坐标系 整体和局部坐标系(主要在建模中涉及) 整体坐标系是以你建模的整个建筑为一体,来确定坐标系的.比如你建一个矩形平面的建筑,整体坐标系一般默认水平方向为X轴,竖直方向为Y轴,以垂直 ...
- Reinvent the Wheel Often
Reinvent the Wheel Often Jason P. Sage Just use something that exists-it's silly to reinvent the whe ...
- 剑指offer面试题12-打印1到最大的n位数
题目: 输入一个数字n,按顺序打印出从1最大的n位十进制数.比方输入3,则打印出1.2.3最大的三位数即999 这道题的主要陷阱就在大数的处理,仅仅要将这个考虑进去,用字符串来表示.就好说了. 那差点 ...
- 如何使用千千静听为MP3添加专辑封面和文字信息
使用千千静听播放器打开某MP3文件,右击该文件,选择属性. 2 点击专辑封面即可添加或更换专辑封面 点击保存到文件再点击重新读取文件即可发现有效了 3 为MP3批量添加添加封面 选中播放列表的所有文件 ...