ASP.NET文件下载函数
在你的Page_Load中添加这样的代码:
Page.Response.Clear();
bool success = ResponseFile(Page.Request, Page.Response, "目的文件名称", @"源文件路径", 1024000);
if (!success)
Response.Write("下载文件出错!");
Page.Response.End();
文件下载函数代码为:
public static bool ResponseFile(HttpRequest _Request,HttpResponse _Response,string _fileName,string _fullPath, long _speed)
{
try
{
FileStream myFile = new FileStream(_fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
BinaryReader br = new BinaryReader(myFile);
try
{
_Response.AddHeader("Accept-Ranges", "bytes");
_Response.Buffer = false;
long fileLength = myFile.Length;
long startBytes = 0;
double pack = 10240; //10K bytes
//int sleep 
相关文档:
GridView使用详解
01 GridView无代码分页排序
02 GridView选中,编辑,取消,删除
03 GridView正反双向排序
04 GridView和下拉菜单DropDownList结合
05 GridView和CheckBox结合
06 鼠标移到GridView某一行时改变该行的背景色方法一
07 鼠标移到GridView某一行时改变该行的背景 ......
许多程序员在做业务开发时往往会在服务器端做用户信息的验证,有没有考虑过用jquery的ajax方法来验证登陆呢?且效果比在服务器端写代码来验证好的多,页面无刷新即可实现实现登陆验证,代码也简单。
现在下面贴出来的是很简单的用jquery的ajax方法来验证登陆的代码,适合刚接触jquery的朋友学习。
前台页面代码:
<he ......
一、修改配置Web.Config文件中的httpRuntime节点
对于asp.net,默认只允许上传4M文件,增加如下配置,一般可以自定义最大文件大小.
一、修改配置Web.Config文件中的httpRuntime节点
对于asp.net,默认只允许上传4M文件,增加如下配置,一般可以自定义最大文件大小.
<httpRuntime
executionTimeout="800"
maxRequestLengt ......
//default.aspx.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Runtime.InteropService ......