我正在使用以下代码将文件从服务器下载到客户端计算机,但是当文件保存时,它会以完整路径名后跟扩展名(例如:Images/24/12/green.png)保存,但我只想存储文件名(绿色.png)。 png)在客户端机器中。如何完成
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)
{
}