Asp.net调用RAR压缩文件与解压文件源码
//压缩
protected void btnY_Click(object sender, EventArgs e)
{
string rar;
RegistryKey reg;
string args;
ProcessStartInfo procStart;
Process process;
try
{
reg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRAR.exe\Shell\Open\Command");
rar = reg.GetValue("").ToString();//获取注册表rar安装路径
reg.Close();
rar = rar.Substring(1, rar.Length - 7);//获取rar安装路径
args = "a -inul -y G:\\temp.rar G:\\1.txt";//这里为rar的压缩命令格式(也可以自行扩展)
procStart = new ProcessStartInfo();
procStart.FileName = rar;
procStart.Arguments = args;//参数
procStart.WindowStyle = ProcessWindowStyle.Hidden;//窗口状态
procStart.WorkingDirectory = Server.MapPath(""); ;//获取或设置要启动的进程的初始目录。
process = new Process();
process.StartInfo = procStart;
process.Start();
Response.Write("<script>alert('压缩成功')</script>");
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
//解压
protected void btnJ_Click(object sender, EventArgs e)
{
string rar;
RegistryKey reg;
string args;
ProcessStartInfo startInfo;
Process process;
try
{
reg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRar.exe\Shell\Open\Command");
rar = reg.GetValue("").ToString();
reg.Close();
rar = rar.Substring(1, rar.Length - 7);
args = " X E:\\temp.rar E:\\";
startInfo = new ProcessStartInfo();
startInfo.FileName = rar;
startInfo.Arguments = args;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
process = new Process();
process.StartInfo = startInfo;
process.Start();
Response.Write("<script>alert('解压成功')</script>");
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
例:把
相关文档:
<%@ 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="s ......
一。①:首先要有这个文件URLRewriter.dll,如果没有,赶快到网上下载一个,并将其放到下面的bin目录里面,并且将其引用添加到下面里面;
②:下面就是Web.Config文件的配置了,当然,配置过程相当简单:
1:先添加这个
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.Rew ......
本文介绍ASP.NET错误处理,以及介绍如果您的应用程序试图登录数据库时没有成功,则显示的错误信息不应该包括它正在使用的用户名。
要创建页中的全局处理程序,请创建 Page_Error 事件的处理程序。要创建ASP.NET应用程序范围的错误处理程序,请在 Global.asax 文件中将代码添加到 Application_Error 方法。只要您的页或应 ......
其实所谓的伪静态页面,就是指的URL重写.
1.首先在web.config里写
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/>
</configSections>
2.在web.config里添加以下节点
<httpHandlers>
< ......