inicio mail me! sindicaci;ón

Asp.net uses RAR to realize a file to compress solution

If RAR program was installed on the server, so Asp.net can call RAR to realize a file to compress compress with solution.

What want an attention nevertheless is, because Web program cannot call the program that the client carries directly (unless use ActiveX, activeX is discarded almost) , if want to come true,let an user compress this locality file with webpage solution so the RAR that uploads the file to the server to call a server to go up again only is compressed, the RAR document that wants solution to compress this locality with manage can upload the file to the server solution pressing is taken again.

The article tells the catalog solution that how carries in the server to compress a file!

Effect graph

Downstage code:

It is quotative content below:

<% . . . @ 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> server carries solution to compress Clear clear month Http://blog.csdn.net/21aspnet/</title>
</head>
<body>
<form Id= "form1" Runat= "server" >
<div>
<asp:BUtton ID= "Button1" Runat= "server" OnClick= "Button1_Click" Text= " compresses " />
<asp:BSolution of Utton ID= "Button2" Runat= "server" OnClick= "Button2_Click" Text= " compresses " /></div>
</form>
</body>
</html>

Tiring-room code:

It is quotative content below:

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)
. . . {
/ / clear clear month Http://blog.csdn.net/21aspnet/
}Protected Void Button1_Click(object Sender, eventArgs E)
. . . {
/ / compress
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″ ;// is gotten or the setting wants the initiative list of started process. The_Process = New Process();The_Process.StartInfo = The_StartInfo;The_Process.Start();
Response.Write(” compresses successful ” );
}Catch (Exception Ex)
. . . {
Response.Write(ex.ToString());
}
}Protected Void Button2_Click(object Sender, eventArgs E)
. . . {
/ / solution is compressed
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(” solution compresses successful ” );
}Catch (Exception Ex)
. . . {
Response.Write(ex.ToString());
}
}
}

Server catalog

Client end explains compression flexible method:

Bookmark:Digg Del.icio.us Reddit

Leave a Comment