<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    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;

    namespace BaseProject.Classes.Util
    {
        public class DownLoadFile
        {
            public bool Down(string filepath)
            {
                HttpResponse response = HttpContext.Current.Response;
                bool succ = false;
                response.Clear();
                System.IO.Stream iStream = null;

                // Buffer to read 10K bytes in chunk:
                byte[] buffer = new Byte[10000];

                // Length of the file:
                int length;

                // Total bytes to read:
                long dataToRead;

                // Identify the file to download including its path.
                //  string filepath = "DownloadFileName";

                // Identify the file name.
                string filename = System.IO.Path.GetFileName(filepath);

                try
                {
                    // Open the file.
                    iStream = new System.IO.FileStream(filepath, System.IO.FileMode.Open,
                                System.IO.FileAccess.Read, System.IO.FileShare.Read);


                    // Total bytes to read:
                    dataToRead = iStream.Length;

                    response.ContentType = "application/octet-stream";
                    response.AddHeader("Content-Disposition", "attachment; filename=" + filename);

                    // Read the bytes.
                    while (dataToRead > 0)
                    {
                        // Verify that the client is connected.
                        if (response.IsClientConnected)
                        {
                            // Read the data in buffer.
                            length = iStream.Read(buffer, 0, 10000);

                            // Write the data to the current output stream.
                            response.OutputStream.Write(buffer, 0, length);

                            // Flush the data to the HTML output.
                            response.Flush();

                            buffer = new Byte[10000];
                            dataToRead = dataToRead - length;
                        }
                        else
                        {
                            //prevent infinite loop if user disconnects
                            dataToRead = -1;
                        }
                    }
                }
                catch (Exception ex)
                {
                    // Trap the error, if any.
                    response.Write("Error : " + ex.Message);
                }
                finally
                {
                    if (iStream != null)
                    {
                        //Close the file.
                        iStream.Close();
                    }
                }

                response.End();
                return succ;
            }
        }
    }

    posted on 2009-04-02 18:34 sanmao 閱讀(184) 評(píng)論(0)  編輯  收藏

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     

    常用鏈接

    留言簿(5)

    隨筆分類

    隨筆檔案

    搜索

    •  

    最新評(píng)論

    閱讀排行榜

    評(píng)論排行榜

    主站蜘蛛池模板: 免费毛片在线视频| 2022国内精品免费福利视频| 亚洲色大成网站www尤物| 亚洲熟妇自偷自拍另欧美| 国产亚洲一卡2卡3卡4卡新区| 边摸边吃奶边做爽免费视频网站 | 四虎成人免费影院网址| 日韩免费高清一级毛片在线| 亚洲国产小视频精品久久久三级| 国产亚洲成AV人片在线观黄桃| 91在线精品亚洲一区二区| 在线亚洲高清揄拍自拍一品区| 亚洲国产成人AV网站| 精品一区二区三区高清免费观看 | 亚洲人成自拍网站在线观看| 特级毛片全部免费播放a一级| 中国极品美軳免费观看| 免费精品国产自产拍在线观看图片| 国产免费av片在线无码免费看| 亚洲午夜精品第一区二区8050| 麻豆亚洲AV永久无码精品久久| 亚洲精品无码成人| 少妇性饥渴无码A区免费| 免费电视剧在线观看| 中文字幕中韩乱码亚洲大片| 亚洲国产精品成人精品小说 | 亚洲AV色欲色欲WWW| 天黑黑影院在线观看视频高清免费| 国产1000部成人免费视频| 亚洲av午夜成人片精品电影| 亚洲欧洲另类春色校园小说| 色噜噜狠狠色综合免费视频| 91人人区免费区人人| 亚洲AV中文无码乱人伦在线视色| 亚洲一区二区三区四区在线观看 | 国产亚洲精品成人AA片| 三年在线观看免费观看完整版中文 | 在线观看亚洲人成网站| 亚洲黄色在线观看视频| 亚洲乱妇熟女爽到高潮的片 | 午夜国产大片免费观看|