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());
}
}
例:把
相关文档:
Web 页面是无状态的, 服务器对每一次请求都认为来自不同用户,因此,变量的状态在连续对同一页面的多次请求之间或在页面跳转时不会被保留。
0、引言
Web 页面是无状态的,服务器对每一次请求都认为来自不同用户,因此,变量的状态在连续对同一页面的多次请求之间或在页面跳转时不会被保留。在用Asp.NET 设计开发一个Web ......
一。①:首先要有这个文件URLRewriter.dll,如果没有,赶快到网上下载一个,并将其放到下面的bin目录里面,并且将其引用添加到下面里面;
②:下面就是Web.Config文件的配置了,当然,配置过程相当简单:
1:先添加这个
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.Rew ......
//详细介绍asp.net获取日期时间的各种格式的函数
DateTime.Now.ToLocalTime().ToString(); // 2009-9-5 20:12:12
//获取日期
DateTime.Now.ToLongDateString().ToString(); // 2009年9月5日
......
更新方法一,直接在GridView中来更新数据.
更新方法二,打开一个新的页面来更新数据.
//更新
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
&nbs ......
其实所谓的伪静态页面,就是指的URL重写.
1.首先在web.config里写
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/>
</configSections>
2.在web.config里添加以下节点
<httpHandlers>
< ......