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