- 浏览: 33685 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
50050192:
扯蛋,误人
[原]JavaSocket实现广播聊天室 -
Dxx23:
受用了!
电子书分享下,谢谢!
[原]Oracle中列自增的方法 -
yulongxiang:
学习了!!!
Ajax的实现原理(asp.net ajax读书笔记)
asp.net利用RAR实现文件压缩解压缩[转载]
如果服务器上安装了RAR程序,那么asp.net可以调用RAR实现文件压缩与解压缩。
不过要注意的是,由于Web程序不能直接调用客户端的程序(除非用ActiveX,ActiveX几乎被废弃),所以如果要想实现让用户把本地文件用网页解压缩只有把文件上传到服务器上再调用服务器上的RAR压缩,同理要解压缩本地的RAR文件可以把文件上传到服务器解压再拿回来。
本文讲怎么在服务器端的目录解压缩文件!
效果图:
<%...@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>服务器端解压缩 清清月儿 http://blog.csdn.net/21aspnet/</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="压缩" />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="解压缩" /></div>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>服务器端解压缩 清清月儿 http://blog.csdn.net/21aspnet/</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="压缩" />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="解压缩" /></div>
</form>
</body>
</html>
后台代码:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Diagnostics;
public partial class _Default : System.Web.UI.Page
...{
protected void Page_Load(object sender, EventArgs e)
...{
//清清月儿 http://blog.csdn.net/21aspnet/
}
protected void Button1_Click(object sender, EventArgs e)
...{
//压缩
String the_rar;
RegistryKey the_Reg;
Object the_Obj;
String the_Info;
ProcessStartInfo the_StartInfo;
Process the_Process;
try
...{
the_Reg = Registry.ClassesRoot.OpenSubKey("Applications\WinRAR.exe\Shell\Open\Command");
the_Obj = the_Reg.GetValue("");
the_rar = the_Obj.ToString();
the_Reg.Close();
the_rar = the_rar.Substring(1, the_rar.Length - 7);
the_Info = " a " + " 1.rar " + " " + "C:\1\1.txt";
the_StartInfo = new ProcessStartInfo();
the_StartInfo.FileName = the_rar;
the_StartInfo.Arguments = the_Info;
the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
the_StartInfo.WorkingDirectory = "C:\1";//获取或设置要启动的进程的初始目录。
the_Process = new Process();
the_Process.StartInfo = the_StartInfo;
the_Process.Start();
Response.Write("压缩成功");
}
catch (Exception ex)
...{
Response.Write(ex.ToString());
}
}
protected void Button2_Click(object sender, EventArgs e)
...{
//解压缩
String the_rar;
RegistryKey the_Reg;
Object the_Obj;
String the_Info;
ProcessStartInfo the_StartInfo;
Process the_Process;
try
...{
the_Reg = Registry.ClassesRoot.OpenSubKey("Applications\WinRar.exe\Shell\Open\Command");
the_Obj = the_Reg.GetValue("");
the_rar = the_Obj.ToString();
the_Reg.Close();
the_rar = the_rar.Substring(1, the_rar.Length - 7);
the_Info = " X " + " 1.rar " + " " + "C:\1";
the_StartInfo = new ProcessStartInfo();
the_StartInfo.FileName = the_rar;
the_StartInfo.Arguments = the_Info;
the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
the_Process = new Process();
the_Process.StartInfo = the_StartInfo;
the_Process.Start();
Response.Write("解压缩成功");
}
catch (Exception ex)
...{
Response.Write(ex.ToString());
}
}
}
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Diagnostics;
public partial class _Default : System.Web.UI.Page
...{
protected void Page_Load(object sender, EventArgs e)
...{
//清清月儿 http://blog.csdn.net/21aspnet/
}
protected void Button1_Click(object sender, EventArgs e)
...{
//压缩
String the_rar;
RegistryKey the_Reg;
Object the_Obj;
String the_Info;
ProcessStartInfo the_StartInfo;
Process the_Process;
try
...{
the_Reg = Registry.ClassesRoot.OpenSubKey("Applications\WinRAR.exe\Shell\Open\Command");
the_Obj = the_Reg.GetValue("");
the_rar = the_Obj.ToString();
the_Reg.Close();
the_rar = the_rar.Substring(1, the_rar.Length - 7);
the_Info = " a " + " 1.rar " + " " + "C:\1\1.txt";
the_StartInfo = new ProcessStartInfo();
the_StartInfo.FileName = the_rar;
the_StartInfo.Arguments = the_Info;
the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
the_StartInfo.WorkingDirectory = "C:\1";//获取或设置要启动的进程的初始目录。
the_Process = new Process();
the_Process.StartInfo = the_StartInfo;
the_Process.Start();
Response.Write("压缩成功");
}
catch (Exception ex)
...{
Response.Write(ex.ToString());
}
}
protected void Button2_Click(object sender, EventArgs e)
...{
//解压缩
String the_rar;
RegistryKey the_Reg;
Object the_Obj;
String the_Info;
ProcessStartInfo the_StartInfo;
Process the_Process;
try
...{
the_Reg = Registry.ClassesRoot.OpenSubKey("Applications\WinRar.exe\Shell\Open\Command");
the_Obj = the_Reg.GetValue("");
the_rar = the_Obj.ToString();
the_Reg.Close();
the_rar = the_rar.Substring(1, the_rar.Length - 7);
the_Info = " X " + " 1.rar " + " " + "C:\1";
the_StartInfo = new ProcessStartInfo();
the_StartInfo.FileName = the_rar;
the_StartInfo.Arguments = the_Info;
the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
the_Process = new Process();
the_Process.StartInfo = the_StartInfo;
the_Process.Start();
Response.Write("解压缩成功");
}
catch (Exception ex)
...{
Response.Write(ex.ToString());
}
}
}
服务器端目录:
客户端解压缩的变通方法:
发表评论
-
用UpDataPanel实现同步提交显示数据
2007-06-08 12:55 694这是我来博客园发的第一篇文章做这个的灵感来自TerryLee的 ... -
Ajax的实现原理(asp.net ajax读书笔记)
2007-06-08 15:07 1178首次加载方式:与传统web应用程序相同。首先用户在游览器输入U ... -
ASP.net自己常用的一些代码[新同学请进]
2007-06-09 01:46 6831.如何在Reapter控件里显示数据库数据?页面部分代码: ... -
SQL Server 2005 For Developers
2007-06-09 18:33 615很多朋友最近在找SQL2005开发版下载的地址,苦于BT下载无 ... -
[原创]Asp.net入门-网络采购系统(1)
2007-06-10 16:14 608大家好,首先欢迎您访问我的博客,在这儿,您如果是一名Asp.n ... -
用Jmail实现邮件发送源代码
2007-06-12 10:53 782以下代码经过测试,没有问题的,可以实现邮件发送。JMail下载 ... -
利用Jmail接收邮件
2007-06-16 00:06 1359/**//// <summary>/// 利用Jm ... -
C#基础概念二十五问[转载]
2007-06-16 10:31 675当初学 C# 时是找个人大概问了一下数据类型和分支语句就开始做 ... -
C# 开发和使用中的23个技巧
2007-06-19 20:39 6241.怎样定制VC#DataGrid列标题? DataGrid ... -
数据库开发者常犯的十大错误,你有吗?
2007-06-21 00:03 750尽管软件发展中的热点技术层出不穷,不断地变化,有一些东西却一 ... -
Net 是未来的趋势, 为什么? [转]
2007-06-23 00:41 519Net姗姗来迟了.但是终于 ... -
使用ADO.NET和C#以编程方式创建 SQL Server 数据库
2007-09-28 15:04 861//Create Button on Form //using ... -
使用ISAPI_Rewrite对asp.net实现URL重写伪静态[转]
2008-04-19 01:08 972ISAPI_Rewrite利用IIS的ISAPI实现URL重写 ... -
利用Mircosoft URLRewriter.dll实现页面伪静态[原]
2008-04-20 01:40 1595昨天,转贴了一篇利用ISAPI筛选器来实现URL伪静态的文章, ... -
[原]利用Wildcard ISAPI Mapping隐藏扩展名
2008-04-23 17:43 733Wildcard ISAPI Mapping,是IIS6中的一 ... -
[转]Log4Net五步走
2008-04-30 02:27 877本文不是教你全面了解log4net,本文只是希望教会你按步就班 ...
相关推荐
如果服务器上安装了RAR程序,那么asp.net可以调用RAR实现文件压缩与解压缩。 不过要注意的是,由于Web程序不能直接调用客户端的程序(除非用ActiveX,ActiveX几乎被废弃),所以如果要想实现让用户把本地文件用网页...
介绍在ASP.NET中怎么利用WinRAR实现文件压缩/解压缩
如果服务器上安装了RAR程序,那么asp.net可以调用RAR实现文件压缩与解压缩。
asp.net解压缩rar文件调用示例:unrar(“e:/www.jb51.net.rar”, “e:/”); 代码如下: using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; namespace BLL { public ...
本篇文章主要介绍了asp.NET中实现文件的压缩和解压,这里整理了详细的代码,有需要的小伙伴可以参考下。
利用反射实现ASP.NET控件和数据实体之间的双向绑定,并且在客户端自动验证输入的内容是否合法 asp.net报表解决方法 SQLDMO类的使用 SQL过程自动C#封装,支持从表到基本存储过程生成 使用SQLDMO控制 SQL Server 使用SQL...
ASP.NET 2.0 动态网站开发教程 PDF格式 清华大学出版社 高等院校计算机教育系列教材 程不功 龙跃进 卓琳 主编 全书不到300页,共21章分为四...全部下载后放到一个文件夹中,解压缩后就可以使用了,呵呵. 祝大家好运!
3、可上传压缩文件(*.zip,*.rar),然后在用户主目录解?,也可对文件(夹)进行压缩; 4、可下载文件、对于文件夹或是多个文件则进行压缩打包成(DownLoad.zip)下载; 5、分割文件(为减轻服务器负担,设定为2~5...
3、可上传压缩文件(*.zip,*.rar),然后利用winrar软件,在用户主目录解圧,也可对文件(夹)进行压缩; 4、可下载文件、对于文件夹或是多个文件则进行压缩打包成(DownLoad.zip)下载; 5、分割文件(为减轻...
说明: 主要功能就是在线压缩, 解压缩... 这个程序是以 7-zip 的命令行版本为载体, 服务器不需要安装7-zip就可以使用本程序. <br>目前压缩格式支持: 7z, zip. 解压缩格式支持: 7z, zip, gzip, bzip2,...
3、可上传压缩文件(*.zip,*.rar),然后在用户主目录解圧,也可对文件(夹)进行压缩;4、可下载文件、对于文件夹或是多个文件则进行压缩打包成(DownLoad.zip)下载;5、分割文件(为减轻服务器负担,设定为2~5个...
下载本程序包至本地并解压缩,将目录里的全部文件上传至根目录。 升级安装 升级前请先备份程序,覆盖bin、content、views文件夹 管理登录 打开http://您的域名/manage/login,初始账号:admin,密码:...
ASP.NET 2.0 动态网站开发教程 <br>PDF格式 清华大学出版社 高等院校计算机教育系列教材 程不功 龙跃进 卓琳 主编 <br>全书不到300页,共21章分为四个部分 第一部分介绍ASP.NET 2.0的基础知识;...
ASP.NET 2.0 动态网站开发教程 <br>PDF格式 清华大学出版社 高等院校计算机教育系列教材 程不功 龙跃进 卓琳 主编 <br>全书不到300页,共21章分为四个部分 第一部分介绍ASP.NET 2.0的基础知识;...
ASP.NET 2.0 动态网站开发教程 <br>PDF格式 清华大学出版社 高等院校计算机教育系列教材 程不功 龙跃进 卓琳 主编 <br>全书不到300页,共21章分为四个部分 第一部分介绍ASP.NET 2.0的基础知识;...
ASP.NET 2.0 动态网站开发教程 <br>PDF格式 清华大学出版社 高等院校计算机教育系列教材 程不功 龙跃进 卓琳 主编 <br>全书不到300页,共21章分为四个部分 第一部分介绍ASP.NET 2.0的基础知识;...
这就是我写这个 AspxZip 在线打包压缩/解压缩程序的原始动机。 AspxZip 的设计目的是想通过友好的Web界面方便的对存放在远程Web服务器上的文档进行压缩打包和解压缩操作,从而方便备份/还原Web服务器上的各种数据。...