c# dynamically rename file upon download request

just change name of file over here

Response.AppendHeader("Content-Disposition","attachment; filename=LeftCorner.jpg");

for example

 string filename = "orignal file name.ext";
 Response.AppendHeader("Content-Disposition","attachment; filename="+ filename  +"");

Downloading a File with a Save As Dialog in ASP.NET


nombre = nombre del archivo + extension (ejemplo.txt)

public void DownloadFile(string ubicacion, string nombre)
{
        Response.Clear();
        Response.ContentType = @"application\octet-stream";
        System.IO.FileInfo file = new System.IO.FileInfo(ubicacion);
        Response.AddHeader("Content-Disposition", "attachment; filename=" + nombre);
        Response.AddHeader("Content-Length", file.Length.ToString());
        Response.ContentType = "application/octet-stream";
        Response.WriteFile(file.FullName);
        Response.Flush();
}