0
我正在使用下面的代碼從服務器下載文件到客戶端機器,但是當文件保存它時,會保存完整路徑名稱,然後是擴展名(例如:Images/24/12/green.png),但我要存儲文件只在客戶端machine.how名(green.png)能不能做到asp.net文件下載問題
string imagePath = String.Format("~/Images/{0}/{1}", item.Value,item.Text);
try
{
System.Net.WebClient req = new System.Net.WebClient();
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.ClearContent();
response.ClearHeaders();
response.Buffer = true;
response.AddHeader("Content-Disposition","attachment;filename=\""+ imagePath + "\"");
//byte[] data = req.DownloadData(imagePath);
//response.BinaryWrite(data);
response.TransmitFile(imagePath);
response.End();
}
catch(Exception ex)
{
}
感謝您分享丟失的信息。 – sai