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");//·¾¶
Ïà¹ØÎĵµ£º
Ö±½Ó»ñµÃÒ³Ãæ²ÎÊý£º
if(!IsPostBack) { //ÅжÏÊÇ·ñÊǵÚÒ»´Î¼ÓÔØ´°Ìå
}
if(Page.PreviousPage!=null){ // ÅжÏÉÏÒ»Ò³ÃæµÄ°´Å¥ÊÇ· ......
ºÜ¶àµØ·½¶¼Ó¦Óõ½Í¼Æ¬ÉÏ´«¹¦ÄÜ£¬ÄÇô¾¿¾¹ÔõÑù¿ÉÒÔʵÏÖÄØ?ÏÂÃæÎÒÀ´¸ø´ó¼Ò½øÐн²½â
ÔÚvisual studioÖÐ×Ô´øµÄÒ»¸ö¿Ø¼þfileupload£¬¿ÉÒÔʵÏִ˹¦ÄÜ£¬ÎÒÒª¸ø´ó¼Ò½éÉܵÄÊÇËüµÄÓ÷¨¡£
Ê×ÏÈҪн¨Ò»¸öÍøÒ³£¨ÏÂÃæÊÇÎÒ´´½¨ºÃµÄÒ»¸öÍøÒ³£©
ÔÚÍøÒ³ÖÐÍϽøfileupload¿Ø¼þ£¬ºóÃæ·ÅÒ»¸öÉÏ´«°´Å¥
ÕâÑù£¬µ±ÎÒÃǵã»÷ÉÏ´«°´Å¥Ê±£¬Í¼ ......
//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 ......
ÔÚÄãµÄPage_LoadÖÐÌí¼ÓÕâÑùµÄ´úÂë:
Page.Response.Clear();
bool success = ResponseFile(Page.Request, Page.Response, "Ä¿µÄÎļþÃû³Æ", @"Ô´Îļþ·¾¶", 1024000);
if (!success)
Response.Write("ÏÂÔØÎļþ³ö´í£¡");
Page. ......
http://zhanglei1286.blog.163.com/blog/static/1895797120091112113019600/
ÔÚºǫ́´úÂëÀ
SQL 2000:
static string StrConn = "server=.;uid=sa;pwd=sa;database=MyCUDS";
SQL2005:
con = new SqlConnection(@"Server=.\SQLExpress;Database=db_CMS;Persist Security Info=True;User ID=sa;Password=Masslong");
......