2007-12-18

.ASHX中下載檔案

context.Response.ContentType = "application/octet-stream"
 
dim FileName as String=mid(url, instrrev(url,"/")+1,url.Length-instrrev(url,"/"))
     dim wc as WebClient= new WebClient()    
     dim b as Byte() = wc.DownloadData(url)
     context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8))
     context.Response.OutputStream.Write(b,0,b.Length)