当前位置:首页 > 网络编程 > WEB编程 > ASP.net >  asp.net利用RAR实现文件压缩解压缩

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

点击次数:19 次 发布日期:2008-11-26 10:45:42 作者:源代码网
源代码网推荐      如果服务器上安装了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>
源代码网推荐  
源代码网推荐  
源代码网推荐  
源代码网推荐  后台代码:
源代码网推荐  
源代码网推荐  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("ApplicationsWinRAR.exeShellOpenCommand");
源代码网推荐   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:11.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("ApplicationsWinRar.exeShellOpenCommand");
源代码网推荐   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());
源代码网推荐   }
源代码网推荐   }
源代码网推荐  }
源代码网推荐  http://blog.csdn.net/21aspnet/archive/2007/06/13/1649810.aspx
源代码网推荐  
源代码网推荐    做人要厚道,请注明转自酷网动力(www.ASPCOOL.COM)。
源代码网推荐


源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华