Last post Jul 16, 2019 11:55 AM by PatriceSc
Jul 15, 2019 03:42 AM|Bulldog248|LINK
I'm using Visual Studio 2017 and SQL Server 2014, VB.
Is there a way to emulate the way you can double click on a filename in Windows Explorer to open a file using Windows file associations? What I would like is to have a button that when I click it it will act like windows and open the attached to the button
file automatically. Any ideas or suggestions?
Jul 15, 2019 06:58 AM|Mikesdotnetting|LINK
Is this in an ASP.NET application? When you say "open", do you mean download?
Jul 15, 2019 07:02 AM|PatriceSc|LINK
Keep in mind that from a browser, for safety reason, the user must give his consent to whatever could be harmful. So for downloaded files you can't bypass this dialog (unless the user changed browser settings on which you have no control).
Edit: if you need further help, tell rather what is your final goal (it is processed by a custom app ???)
Jul 15, 2019 06:16 PM|Bulldog248|LINK
Below is a code sample where I open the pdf viewer to a specific file:
Protected Sub Button16_Click(sender As Object, e As System.EventArgs)
Dim SCH1 As String = String.Empty
If FormView1.CurrentMode = FormViewMode.ReadOnly Then
Dim SName As Label = TryCast(FormView1.FindControl("Schematic_PartLabel"), Label)
Dim SNameDD As DropDownList = TryCast(FormView1.FindControl("DropDownList5"), DropDownList)
If SNameDD.Visible = True Then
SCH1 = SCHpdf & SNameDD.SelectedItem.Text & ".pdf"
SCH1 = SCHpdf & SName.Text & ".pdf"
Response.ContentType = "application/pdf"
Context.Response.AddHeader("Content-Disposition", "inline; filename=" + SCH1)
The problem is that I have a different type of file I would like to open with a different viewer. In Windows explorer I can double click on the filename and it automatically associates with the correct viewer. How can I adapt the above code for a different
viewer? Filename extension = ".sldprt"; associated application = "EModelViewer.exe".
Jul 15, 2019 08:32 PM|Mikesdotnetting|LINK
You can't associate file types with viewers on the client machine. Only the user can do that - if they even have a appropriate viewer installed. All you can do is to ensure that the correct content type is specified.
Jul 16, 2019 11:55 AM|PatriceSc|LINK
According to https://www.drupal.org/project/fileframework/issues/414690 see what happens when using the "application/sldworks" mime type (and of course use the .SLDPRT extension instead
The mime type is to telll which kind of content you are sending back so that the browser can known (through the OS) which app could handle this content.