ASP.NETÏÂÔØÎļþ³öÏÖÌáʾ¿ò»òÕßÖ±½ÓÏÔʾÔÚä¯ÀÀÆ÷ÖÐ
ASP.NETÏÂÔØÎļþ³öÏÖÌáʾ¿ò»òÕßÖ±½ÓÏÔʾÔÚä¯ÀÀÆ÷ÖÐ
¼¼Êõ½»Á÷ 2008-06-20 11:44 ÔĶÁ42 ÆÀÂÛ0
×ֺţº ´ó´ó ÖÐÖРСС
1£º³öÏÖÎļþÏÂÔØÌáʾ¿ò
string strFile="F:\\a.doc";//·¾¶¸ù¾Ýʵ¼ÊÇé¿ö¶ø¶¨
if(!System.IO.File.Exists(strFile))
{
Response.Write("<script language='javascript'>alert('¶Ô²»Æð£¬Îļþ²»´æÔÚ£¡');</script>");
return;
}
Response.Clear();
Response.ClearHeaders();
Response.Charset = "GB2312";
Response.ContentEncoding =System.Text.Encoding.UTF8;
Response.ContentType = "application/octet-stream";
FileInfo fi=new FileInfo(strFile);
Response.AddHeader("Content-Disposition","attachment; filename=" + HttpUtility.UrlEncode(fi.Name)) ;
Response.AddHeader("Content-Length",fi.Length.ToString());
byte[] tmpbyte=new byte[1024*8];
FileStream fs=fi.OpenRead();
int count;
while((count=fs.Read(tmpbyte,0,tmpbyte.Length))>0)
{
Response.BinaryWrite(tmpbyte);
Response.Flush();
}
fs.Close();
Response.End();
2£ºÖ±½ÓÔÚä¯ÀÀÆ÷Öдò¿ª
string strFile="F:\\a.doc";//·¾¶¸ù¾Ýʵ¼ÊÇé¿ö¶ø¶¨
Response.Clear();
Response.ClearHeaders();
Response.Charset = "GB2312";
Response.ContentEncoding =System.Text.Encoding.UTF8;
Response.ContentType = "application/msword";
Response.WriteFile(strFile);
3£º·â×°³ÉÀàµÄÎļþÏÂÔØ·½·¨µÄд·¨
///
/// ÔÚÒ³ÃæÖÐÏÔʾÏÂÔØ¶Ô»°¿ò²¢ÏÂÔØÖ¸¶¨µÄÎļþ£¬webPageÎªÒ³Ãæ¶ÔÏóÒýÓã¨Ò»°ã¸³ÖµPage)£¬filePathΪÏÂÔØÎļþÐéÄâ·¾¶£¬fileNameΪ¶Ô»°¿òÖÐÏÔʾµÄÎļþÃû
///
public static void DownloadFile(Page webPage, string filePath, string fileName)
{
HttpResponse Response = webPage.Response;
FileInfo aFile = new FileInfo(webPage.Server.MapPath(filePath));
Response.Clear();
Response.ClearHeaders();
Response.BufferOutp
Ïà¹ØÎĵµ£º
ÔÚWeb±à³Ì¹ý³ÌÖУ¬´æÔÚןܶలȫÒþ»¼¡£±ÈÈçÔÚÒÔǰµÄASP°æ±¾ÖУ¬CookieΪ·ÃÎÊÕߺͱà³ÌÕß¶¼ÌṩÁË·½±ã£¬²¢Ã»ÓÐÌṩ¼ÓÃܵŦÄÜ¡£´ò¿ªIEä¯ÀÀÆ÷£¬Ñ¡Ôñ“¹¤¾ß”²Ëµ¥ÀïµÄ“InternetÑ¡Ï¬È»ºóÔÚµ¯³öµÄ¶Ô»°¿òÀïµ¥»÷“ÉèÖÔ°´Å¥£¬Ñ¡Ôñ“²é¿´Îļþ”°´Å¥£¬ÔÚµ¯³öµÄ´°¿ÚÖУ¬¾Í»áÏÔʾӲÅÌÀï ......
RowÄÚÕÒLabel¿Ø¼þ
//ÄÚ²¿¿Ø¼þʼþ
protected void LinkButton11_Click1(object sender, EventArgs e)
{
//ɾ³ý¶ÔÓ¦µÄÊÂÎñ
int ......
1¡¢ÔÚcompilation Ï£¬ÇëÉèÖÃdebug=false £¬ÈçÏ£º
default Language="c#" debug="false">
2¡¢ÇëʹÓÃServer.Transfer´úÌæResponse.Redirect¡£
3¡¢Ê¹ÓÃValidator¿Ø¼þ£¬ÇëÒª¾³£¼ì²éPage.IsValid¡£
4¡¢ÇëʹÓÃforeachÑ»·£¬¶ø²»ÊÇΪ×Ö·û´®µü´úÑ»·¡£
5¡¢ÇëʹÓÿͻ§¶ËÑéÖ¤·½Ê½(²»ÒªÃ¿´Î¶ ......
´°Ìå´úÂë:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using AgentObjects;
using SpeechLib;
using System.Web;
using System.Threading;
using System.Text.RegularExpressio ......