Exemple #1
0
        private void preHandlerDown(string FullName)
        {
            if (string.IsNullOrEmpty(FullName))
            {
                return;
            }
            FileHelp     flp = new FileHelp();
            MemoryStream ms  = flp.FileToStream(FullName);

            Response.ContentType = "application/octet-stream";
            long length = 0;

            if (ms != null && ms.Length > 0)
            {
                length = ms.Length;
                Response.BinaryWrite(ms.ToArray());
            }
            else
            {
                Response.ContentType = "text/html";
                Response.Write("<script>alert('日志不存在,或者无内容!');window.opener = null;window.close();</script>");
                Response.End();
                return;
            }
            string fileNmae = "";
            // flp.GetFileNameforFullName(FullName);
            FileInfo fileinfo = flp.Getfile(FullName);

            if (fileinfo != null)
            {
                fileNmae = fileinfo.Name;
                if (fileinfo.Extension.ToLower() != ".log")
                {
                    fileNmae += ".log";
                }
            }
            Response.AddHeader("Content-Disposition", "attachment; filename=" + fileNmae + ";Content-Length=" + length);
            Response.Flush();
            Response.End();
        }