0

I am converting multiple emf files to Vsdx files using c# and I wanted to download all converted vsdx files with zip file.

But instead of downloading directly I want it to open a download prompt to choose the location of file to be downloaded.

PS: I wanted to show the popup to select the path to download file

public ActionResult DownloadFile(string filePath)
{
   string id = Convert.ToString(Session["id"]);
   workingDirectory = HttpContext.Server.MapPath("~");
   string fullpath = Path.Combine(workingDirectory, "output", id, "vsdx", filePath);
   return File(fullpath, MimeTypes.GetMimeType(fullpath), Path.GetFileName(fullpath));
}

1 Answers1

0

try this:

It will display a dialog box in the browser and the user will select on where to save the file

protected void DownloadFile_Click(object sender, EventArgs e)
 {
  String Filepath;
  System.IO.FileInfo file =  new System.IO.FileInfo(Filepath); // full file path on disk
  Response.ClearContent(); // Clear previous content
  Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
  Response.AddHeader("Content-Length", file.Length.ToString());
  Response.ContentType = "application/pdf";
  Response.TransmitFile(file.FullName);
  Response.End();
 }