日期:2014-05-18 浏览次数:20505 次
public void DownFile(string url) { if (string.IsNullOrEmpty(url)) return; try { WebClient UrlFile = new WebClient(); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ClearHeaders(); HttpContext.Current.Response.BufferOutput = false; HttpContext.Current.Response.ContentType = "application/octet-stream"; HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8)); byte[] b = UrlFile.DownloadData(url); HttpContext.Current.Response.BinaryWrite(b); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.End(); } catch { } }