ÓÃC#(ASP.NET)ÔõôʵÏÖÎļþÏÂÔع¦ÄÜ
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
//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.Length.ToString());
Response.AddHeader("Content-Transfer-Encoding", "binary");
Response.ContentType = "application/octet-stream";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
Response.WriteFile(fileInfo.FullName);
Response.Flush();
Response.End();
}
//WriteFile·Ö¿éÏÂÔØ
protected void Button3_Click(object sender, EventArgs e)
{
string fileName = "aaa.txt";//¿Í»§¶
Ïà¹ØÎĵµ£º
ÓÃAsp.NetÉÏ´«Îļþ,Ê×Óõ½µÄÊÇFileUpload¿Ø¼þ
<asp:FileUpload ID="FileUpload1" runat="server" /><br />
<asp:Button ID="btn" runat="server" Text="È·¶¨" OnClick="btn_Click"/>
C#´úÂë
protected void btn_Click(object sender, EventArgs e)
{
//ÅÐ¶Ï ......
·½·¨Ò»£º
HtmlProxy.cs£º
using System.Text;
using System.IO;
/// <summary>
/// HtmlProxy µÄժҪ˵Ã÷
/// </summary>
public class HtmlProxy
{
public HtmlProxy()
{
//
......
1 ʹÓñê×¼HTMLÀ´½øÐÐͼƬÉÏ´«
ǰ̨´úÂ룺
<body>
<form id="form1" runat="server">
<div>
<table>
&nbs ......
´úÂëºÜ¼òµ¥µÄ,ÎÒ°ÑÎÒƽʱд¹ýµÄÌù³öÀ´¸ø´ó¼Ò¿´¿´:
if (bResult == true) //µÇ¼µÄÓû§ÃûºÍÃÜÂëÕýÈ·
{
//±£´æµÇ¼µÄÓû§Ãû
Session["LoginUser"] = FormatString.Replace(txtLoginUser.Text); //ÕâÀï¾ÍÊǸøsession¸³ÖµÁË ......