Quote:
WebClient webClient = new WebClient();
webClient.DownloadFile(Server.MapPath("~/Images/") + e.CommandArgument, @"d:\myfile.jpg");
That code is running
on the server. It is copying the image to the root of drive
D:
on the server.
It might
appear to work when you debug the code in Visual Studio. But that's only because, in that specific case, the client and the server are the same computer.
As soon as you deploy your code to a real server, you'll see that the file is being saved on the server, not on the client.
The rest of your code is the only way to send a file to the client:
Response.Clear();
Response.ContentType = "application/octect-stream";
Response.AppendHeader("content-disposition", "filename=" + e.CommandArgument);
Response.TransmitFile(Server.MapPath("~/Images/") + e.CommandArgument);
Response.End();
NB: The user will be prompted to select where they want to save the file. There is no way to control where, or even if, the user saves the file.