学院首页 软件应用 编程开发 创意设计 认证培训 软件论坛
ASP ASP.NET PHP JSP SQL MYSQL Java VB

您的位置:学院 >> 编程开发 >> ASPNET >> asp.net 利用RAR实现文件压缩解压缩


asp.net 利用RAR实现文件压缩解压缩


  如果服务器上安装了RAR程序,那么asp.net可以调用RAR实现文件压缩与解压缩。

  不过要注意的是,由于Web程序不能直接调用客户端的程序(除非用ActiveX,ActiveX几乎被废弃),所以如果要想实现让用户把本地文件用网页解压缩只有把文件上传到服务器上再调用服务器上的RAR压缩,同理要解压缩本地的RAR文件可以把文件上传到服务器解压再拿回来。

  本文讲怎么在服务器端的目录解压缩文件!

  前台代码:

以下是引用片段:
 <%...@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 
   
   
   
   
   
   服务器端解压缩 
   
   
    
   
 
    
   
 
    
   
   

以下是引用片段:
后台代码:
  
  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());
   }
   }
  }


技术文章快速查找

栏目导航
软件应用
·操作系统 ·杀毒防黑 ·应用软件
·聊天软件 ·网络软件  
Web开发
·ASP ·JavaScript ·CGI
·JSP ·VbScript ·Web服务器
·PHP ·XML  
开发语言
·VB ·VC ·ASP.NET
·Java ·C/C++ ·Delphi
数据库开发
·MySQL ·SQL/Access ·PowerBuilder
·Oracle ·DB2  
网站设计
·Flash ·Dreamweaver ·HTML/CSS
·Fireworks ·FrontPage  
平面设计
·Photoshop ·CorelDraw ·AutoCAD
·FreeHand ·Illustrator ·3DsMAX
媒体动画
·Director ·Authorware ·Maya
·视频处理    


相关软件 产品库推荐
·笔记本 ·台式机 ·服务器
·数码相机 ·手机 ·GPS
·DV摄像机 ·MP3 ·MP4
·CPU ·硬盘 ·内存
·主板 ·显卡 ·显示器
·打印机 ·投影机 ·路由器

还没人留言,抢个先,哈哈!
对"asp.net 利用RAR实现文件压缩解压缩"的评论 - 快速回贴
内容:
  [完成后可按Ctrl+Enter发布]

百度中 asp.net 利用RAR实现文件压缩解压缩 相关内容
Google搜索中 asp.net 利用RAR实现文件压缩解压缩 相关内容
雅虎中 asp.net 利用RAR实现文件压缩解压缩 相关内容
Sogou搜索中 asp.net 利用RAR实现文件压缩解压缩 相关内容

相关软件 最新回复帖子:

·没有mysql支持时的替代方案
·一个可以发送附件及HTML格式邮件的PHP类
·AutoCAD打造精致三维鸟笼实例详解
·Photoshop自定义水晶字特效样式
·AutoCAD三维基础实例教程
·PS为黑背景长发美女照片抠图换背
·用Photoshop自制个性摩托车贴花小经验
·轻松几步将美女照片处理为手工素描
·巧用Photoshop画笔轻松绘制创意特效
·用Photoshop通道将模糊肖像照片清晰化


  相关软件 asp.net 利用RAR实现文件压缩解压缩相关文章
关于 ASP.NET 在IIS一些问题的经验总结 请慎用ASP.Net的validateRequest=
关于 ASP.NET 技术的学习顺序问题 用 ASP.Net 中的自带类进行MD5加密
ASP.NET 生成静态页面实现方法 ASP.NET 2.0中保证应用程序的安全
ASP.NET移动开发之SelectionList控件 在ASP.NET 2.0中建立站点导航层次
在ASP.NET 2.0中使用样式、主题和皮肤 ASP.NET中利用VWD操作数据库
ASP.NET 2.0高级数据处理之数据绑定 ASP.NET 2.0移动开发之列表控件
ASP.NET中为GridView添加删除确认提示框 ASP.NET2.0的multiview和wizard控件
用ASP.NET2.0在数据库中存储二进制文件 ASP.NET定制简单的错误处理页面
ASP.NET中上传文件到数据库 在ASP.NET AJAX中别使用mode
探讨ASP.NET 2.0的Web控件改进之概述 ASP.NET实现投票结果的图片进度条显示