推薦:ASP.NET筆記之 Repeater的使用
本篇文章小編為大家介紹,ASP.NET筆記之 Repeater的使用。需要的朋友參考下
string filePath = page.Server.MapPath("..")+"//Files//" +FileName;
System.IO.StreamWriter sw = System.IO.File.CreateText(filePath);
sw.Write(tw.ToString());
sw.Close();
DownFile(httpResponse,FileName,filePath);
httpResponse.End();
}
private static bool DownFile(System.Web.HttpResponse Response,string fileName,string fullPath)
{
try
{
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition","attachment;filename=" +
HttpUtility.UrlEncode(fileName,System.Text.Encoding.UTF8) + ";charset=GB2312");
System.IO.FileStream fs= System.IO.File.OpenRead(fullPath);
long fLen=fs.Length;
int size=102400;//每100K同時(shí)下載數(shù)據(jù)
byte[] readData = http://www.CuoXIn.com/yongle_tianya/archive/2011/10/24/new byte[size];//指定緩沖區(qū)的大小
if(size>fLen)size=Convert.ToInt32(fLen);
long fPos=0;
bool isEnd=false;
while (!isEnd)
{
if((fPos+size)>fLen)
{
size=Convert.ToInt32(fLen-fPos);
readData = http://www.CuoXIn.com/yongle_tianya/archive/2011/10/24/new byte[size];
isEnd=true;
}
fs.Read(readData, 0, size);//讀入一個(gè)壓縮塊
Response.BinaryWrite(readData);
fPos+=size;
}
fs.Close();
System.IO.File.Delete(fullPath);
return true;
}
catch
{
return false;
}
}
分享:.net 中的SqlConnection連接池機(jī)制詳解
.net 中通過(guò) SqlConnection 連接 sql server,我們會(huì)發(fā)現(xiàn)第一次連接時(shí)總是很耗時(shí),但后面連接就很快,這個(gè)其實(shí)和SqlConnection 的連接池機(jī)制有關(guān)
|
新聞熱點(diǎn)
疑難解答
圖片精選