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 ...
随机推荐
- NYOJ-61 传纸条(一)
传纸条(一) 时间限制:2000 ms | 内存限制:65535 KB 难度:5 描述 小渊和小轩是好朋友也是同班同学,他们在一起总有谈不完的话题.一次素质拓展活动中,班上同学安排做成一个m行 ...
- Linux经常使用命令(三) - pwd
Linux中用 pwd 命令来查看"当前工作文件夹"的完整路径. 简单得说,每当你在终端进行操作时.你都会有一个当前工作文件夹. 在不太确定当前位置时.就会使用pwd来判定当前文件 ...
- CentOS上编译安装OpenCV-2.3.1与ffmpeg-2.1.2
已測试环境: CentOS 6.3 32bit CentOS 6.5 64bit 以前在CentOS 6.3 32bit安装过OpenCV,參见CentOS 6.3中安装OpenCV2.3.1,现在换 ...
- idea unicode自动转码设置
idea unicode自动转码设置 File > Settings > Editor > File Encodings 右侧 Properties Files 中 选中 Trans ...
- CSS半透明兼容写法
filter: Alpha(opacity=10); -moz-opacity:0.1; opacity:0.1; 例如: background:#A5CD40; filter: Alpha(opac ...
- 【pyhon】理想论坛爬虫1.05版,将读取和写DB分离成两个文件
下午再接再厉仿照Nodejs版的理想帖子爬虫把Python版的也改造了下,但美中不足的是完成任务的线程数量似乎停滞在100个左右,让人郁闷.原因还待查. 先把代码贴出来吧,也算个阶段性成果. 爬虫代码 ...
- POJ--2449--Remmarguts' Date【dijkstra_heap+A*】第K短路
链接:http://poj.org/problem?id=2449 题意:告诉你有n个顶点,m条边.并把这些边的信息告诉你:起点.终点.权值.再告诉你s.t.k.需求出s到t的第k短路,没有则输出-1 ...
- C++ extern c 用法
一.整体代码 01.cpp #include <iostream> #include <stdio.h> #include "add.h" using na ...
- 使用js对select动态添加和删除OPTION
<select id="ddlResourceType" onchange="getvalue(this)"> </select> 动态 ...
- Linux安装 微信开发者工具(deepin linux ubt)
一.环境:: deepin linux15.4.1 二.安装过程: 2.1 安装wine sudo apt-get install wine 2.2 安装nwjs-sdk 2.2.1 下载linux版 ...