ASP.Net中的几种文件下载方法
//TransmitFile实现下载
protected void Button1_Click(object sender, EventArgs e)
{
/*
微软为Response对象提供了一个新的方法TransmitFile来解决使用Response.BinaryWrite
下载超过400mb的文件时导致Aspnet_wp.exe进程回收而无法成功下载的问题。
代码如下:
*/
Response.ContentType = "application/x-zip-compressed";
Response.AddHeader("Content-Disposition", "attachment;filename=z.zip");
string filename = Server.MapPath("DownLoad/z.zip");
Response.TransmitFile(filename);
}
//WriteFile实现下载
protected void Button2_Click(object sender, EventArgs e)
{
/*
using System.IO;
*/
string fileName = "asd.txt";//客户端保存的文件名
string filePath = Server.MapPath("DownLoad/aaa.txt");//路径
FileInfo fileInfo = new FileInfo(filePath);
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
Response.AddHeader("Content-Length", fileInfo.Lengt
相关文档:
1、添加Web.config, < system.web>< /system.web>中添加< customErrors mode="On"
defaultRedirect="ApplicationErroy.aspx" >< /customErrors>节点,
2、添加Global.asax文件,找到Application_Error事件,加入以下代码:
//这是添加了一个全局应用程 ......
我想使用一个TreeView控件来显示文件
夹的结构,可以在Asp.net中没有默认的Treeview控件,于是,我查找了相关资料,知道微软发布了它的控件IEWebControls.我下载
了该控件,并安装到了自己的机器上。
1、下载:
下载的网址
http://msdn.microsoft.com/downloads/s
amp
les/internet/
[url=/code/as ......
好多人对相对路径与绝对路径老是混淆记不清楚,我从整理了一下,希望对大家的认识有帮助。
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1.Request.ApplicationPath->当前应用的目录
Jsp中, ApplicationPath指的是当前的application(应用程序)的目录,ASP.NET中也是这个意思。
对应 ......
1、解决Cookie更新滞后的问题
先写入一个过期的Cookie,再添加一个新的Cookie就OK了。示例代码如下所示:
protected void btnSearch_Click(object sender, EventArgs e)
{
//生成条件表达式
string where = bll.GetWhereSql(Int32.Parse(ddlCate.SelectedValue),
......
之前写过一系列的ExtJS的使用教程,但是基本比较零散,本文主要对其进行归纳总结。希望对于初学或者复习extjs的同盟们有所帮助。
列表清单如下所示:
1、ExtJS的使用方法汇总(1)——配置和表格控件使用 :
http://blog.csdn.net/rocket5725/archive/2009/09/09/4535323.aspx
2、ExtJS的使用方法汇总(2)&mdash ......