ASP.NETÎļþÏÂÔغ¯ÊýʹÓÃ
ASP.NETÎļþÏÂÔغ¯ÊýʹÓÃÊÇʲôÇé¿öÄØ£¿ÔÚÄãµÄPage_LoadÖÐÌí¼ÓÕâÑùµÄ´úÂë:
Page.Response.Clear();
bool success = ResponseFile(Page.Request, Page.Response, "Ä¿µÄÎļþÃû³Æ", @"Ô´Îļþ·¾¶", 1024000);
if (!success) Response.Write("ÏÂÔØÎļþ³ö´í£¡"); Page.Response.End();
ASP.NETÎļþÏÂÔغ¯Êý´úÂëΪ:
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 = 200;
//ÿÃë5´Î ¼´5*10K bytesÿÃë int sleep = (int)Math.Floor(1000 * pack / _speed) + 1;
if (_Request.Headers["Range"] != null)
{
_Response.StatusCode = 206;
string[] range = _Request.Headers["Range"].Split(new char[] {'=', '-'});
startBytes = Convert.ToInt64(range[1]);
}
_Response.AddHeader("Content-Length", (fileLength - startBytes).ToString());
if (startBytes != 0) {
//Response.AddHeader("Content-Range", string.Format(" bytes {0}-{1}/{2}", startBytes, fileLength-1, fileLength));
}
_Response.AddHeader("Connection", "Keep-Alive");
_Response.ContentType = "application/octet-stream";
_Response.AddHeader("Content-Disposition","attachment; filename=" + HttpUtility.UrlEncode(_fileName,System.Text.Encoding.UTF8) ); br.BaseStream.Seek(startBytes, SeekOrigin.Begin);
int maxCount = (int) Math.Floor((fileLength - startBytes) / pack) + 1;
for (int i = 0; i < maxCount; i++) { if (_Response.IsClientConnected) { _Response.BinaryWrite(br.ReadBytes(int.Parse(pack.ToString()))); Thread.Sleep(sleep);
} else { i=maxCount;
}
} }
catch
{
return false;
}
finally
{
br.Close();
myFile.Close();
}
}
catch
{
return false;
}
return true;
}
ÕâÑù¾ÍʵÏÖÁË
Ïà¹ØÎĵµ£º
/// <summary>
/// ×Ö·û´®Çиî
/// </summary>
/// <param name="p_SrcString"></param>
/// <param name="p_Length"></param>
/// <returns></returns>
public static string GetSubString(string p_SrcString, int ......
ASP.NETµÄÒ³Ãæ³õʼ»¯ÓëʼþÏê½â
Ò»¡¢³õʼ»¯
¡¡¡¡·µ±Ò³Ãæ±»Ìá½»ÇëÇóµÚÒ»¸ö·½·¨ÓÀÔ¶Êǹ¹Ô캯Êý¡£Äú¿ÉÒÔÔÚ¹¹Ô캯ÊýÀïÃæ³õʼһЩ×Ô¶¨ÒåÊôÐÔ»ò¶ÔÏ󣬲»¹ýÕâʱºòÒòΪҳÃ滹ûÓб»ÍêÈ«³õʼ»¯ËùÒÔ¶àÉÙ»áÓÐЩÏÞÖÆ¡£ÌرðµØ£¬ÄúÐèҪʹÓÃHttpContext¶ÔÏó¡£µ±Ç°¿ÉÒÔʹÓõĶÔÏó°üÀ¨QueryString, FormÒÔ¼°Cookies¼¯ºÏ£ ......
ÎÒÓÃC# дµÄÒ»¸öWindowsÓ¦ÓóÌÐòÀï,ÓÃTeeChartʵÏÖÁËÒ»¸öÕÛÏßͼ.
XÖáÊÇʱ¼ä,YÖáÊÇÊýÖµ,¼ÓÁ˸öÒ»´¹Ö±µÄCursorTool.
Êó±êÔÚͼÉÏÒƶ¯Ê±,´¹Ö±µÄCursorTool»á¸ú×ÅÊó±êÅÜ,²¢´¥·¢CursorToolµÄChangeʼþ.
ÔÚCursorToolµÄChangeʼþÀï,
ÎÒÈ¡³öÁËÇúÏßÓë´¹Ö±µÄÏß½»µã´¦µÄ,ʱ¼äÖµ,ºÍÊýÖµ.
ÎÒдÕâ¸öWindow³ÌÐòµÄÖ÷ÒªÉϵÄÊÇÃþ ......
ת£ºhttp://www.cnblogs.com/kumaws/articles/web_architecture.html
Ïà¶ÔÓÚ²»Í¬µÄÐèÇó£¬ÍøÕ¾µÄ´óС£¬¿ª·¢¸´ÔӶȣ¬³É±¾£¬ÍøÕ¾µÄ¼Ü¹¹Ò²·ÖÐí¶àÖÖ¡£
´ó¶àÊýСÐÍÍøÕ¾£¬ÐèÇó½ÏΪ¼òµ¥£¬°²È«ÐÔÒªÇ󲻸ߣ¬¿ª·¢Ê±¼ä¶Ì¡£Ò»°ãÕâÑùµÄÍøÕ¾£¬»¹»áÓÐÒ»¸öÓëÊý¾Ý¿âÖ®¼äµÄ½»»¥¡£ÓÃAsp.NetÖÐÌṩµÄ¿Ø¼þ£¬ÍêÈ«¿ÉÒÔÂú×㿪·¢µÄÒªÇó¡£Ò»° ......