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());
}
}
例:把
相关文档:
本文介绍ASP.NET错误处理,以及介绍如果您的应用程序试图登录数据库时没有成功,则显示的错误信息不应该包括它正在使用的用户名。
要创建页中的全局处理程序,请创建 Page_Error 事件的处理程序。要创建ASP.NET应用程序范围的错误处理程序,请在 Global.asax 文件中将代码添加到 Application_Error 方法。只要您的页或应 ......
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Xml;
namespace jiu ......
为了能让来自不同文化习惯或使用不同语言作为母语的访客能够阅读我们的网站,则必须为这些读者提供用他们自己的语言查看网页的方法。一种方法是分别用各语言重新创建页面,但这种方法可能需要大量工作量、容易出错并且在更改原始页时很难维护。利用 ASP.NET,可以使创建的页面基于浏览器的首选语言设置或用户显式选择的语言 ......
其实所谓的伪静态页面,就是指的URL重写.
1.首先在web.config里写
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/>
</configSections>
2.在web.config里添加以下节点
<httpHandlers>
< ......