這裏我想下載鏈接中的空Excel文件按鈕單擊物理路徑中的事件。 我的代碼是如何下載物理路徑中的空Excel文件
HttpResponse httpResponse = HttpContext.Current.Response;
httpResponse.Clear();
httpResponse.ClearContent();
httpResponse.ClearHeaders();
httpResponse.AddHeader("content-disposition", "attachment;filename=" + txt1.Text + ".xls");
string strpath = ConfigurationManager.AppSettings["Downloads"].ToString() + txt1.Text;
httpResponse.ContentType = "application/vnd.ms-excel;";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
string style = @"<style> .textmode { mso-number-format:\@; } </style>";
httpResponse.Write(style);
httpResponse.Output.Write(sw.ToString());
httpResponse.Flush();
httpResponse.Close();
httpResponse.End();
我Web.Config中AddKey是
<add key="Downloads" value="C:\Users\MyName\Desktop\Downloads"/>
在這裏,我怎麼給它添加鍵值
「Down load」=>「下載」 – Fluff
我想下載 – Exception
你想t從HTTP URL下載文件(xls)並將其存儲在文件系統中? –