Answered by:
Downloading files

Question
-
User-1623383795 posted
I would like some guidance on the following problem, I have filenames stored in my database, and the actually doc is saved to HDD. I am the stage where I would like select a file to download it.
Does this make sense, appreciate any help thanks
Tuesday, March 27, 2012 3:04 PM
Answers
-
User-750898090 posted
WinForm - Spawn a process that simulates the user double clicking on the file
Dim fileName As String = "MY_FILE" Dim process = New System.Diagnostics.Process() process.StartInfo = New System.Diagnostics.ProcessStartInfo() With { _ .UseShellExecute = True, _ .FileName = fileName _ } process.Start()
or a short hand version
System.Diagnostics.Process.Start("My-file-name.ext");
Note the user must have the appropriate program to open the file (e.g. Adobe Reader for PDF, MS Word for .doc/docx, etc)
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, March 27, 2012 3:37 PM
All replies
-
User-750898090 posted
Winform or Webform?
Tuesday, March 27, 2012 3:33 PM -
User-750898090 posted
WinForm - Spawn a process that simulates the user double clicking on the file
Dim fileName As String = "MY_FILE" Dim process = New System.Diagnostics.Process() process.StartInfo = New System.Diagnostics.ProcessStartInfo() With { _ .UseShellExecute = True, _ .FileName = fileName _ } process.Start()
or a short hand version
System.Diagnostics.Process.Start("My-file-name.ext");
Note the user must have the appropriate program to open the file (e.g. Adobe Reader for PDF, MS Word for .doc/docx, etc)
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, March 27, 2012 3:37 PM -
User-750898090 posted
Web
string responseFile = Server.MapPath("~/" + FileName); Response.ContentType = "text/xml"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + FileName); Response.TransmitFile(responseFile); Response.Flush();
Tuesday, March 27, 2012 3:41 PM -
User-1623383795 posted
Webform
Tuesday, March 27, 2012 5:24 PM