Click here to Skip to main content
15,905,563 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All

How to file download Dialog in Internet Explorer in vb

What I have tried:

I tried to search on google a lot but not found any good solution.
Updated 10-Apr-19 1:08am

Nirav, if I understand correctly, you want to send the .XLSX file from the server to the browser, but to give the user the option to SAVE the file rather than have it automatically open in Excel?
If that's the case, then in your server-side VB.Net code, do something like:
Dim filename as string = "demo.xlsx"                    '' 
        Dim fullfilename as string = server.mappath([filename]) '' Get the full local filesystem filename
        Response.Clear()                                        '' We don't want to send any of the current page back
        Response.Headers.Add("Filename", filename)             '' Set the filename 
        HttpContext.Current.Response.AddHeader("Content-Disposition", String.Format("attachment;filename={0}.xlsx", filename))  '' This tells the browser that the content is an ATTACHMENT, i.e. to save it, not open it
        Response.ContentType = "vnd.openxmlformats-officedocument.spreadsheetml.sheet"  '' The Content-type for XLSX spreadsheets
        Response.WriteFile(fullfilename)                         '' Send the actual file content
        Response.End()                                           '' End the response - nothing else gets sent

The important part here is the content-disposition, which tells the browser to "download" rather than open it. How the browser deals with this is browser-specific; Chrome will always put it in the Downloads folder, IE may prompt you for a location. Hopefully the above will help you, even if only with some keywords to research further.

Good luck!
Share this answer
It is depending upon your skill over frontend side technologies like jquery, javascript.

1) You can create a list of files
2) Set download button or link over there
3) You can use modal popup or any div (fadeIn/fadeOut) as a dialogue and you can write a logic according to your need.
4) You can download the file on click of actions of a dialogue

Rest, You don't have any command over browser's native behavior.
Share this answer
.net developer123456789 8-Apr-19 5:29am    
Thanks Nirav

Please give me link for above your comments so I will implement.

You can't really "Open a file download dialog" in a web browser because it doesn't really have direct access to the server folders - or at least it shouldn't.

Instead you would have to create a webpage which listed the folders and their content and show that to the user. when they select a file, you can send the file to them, but you will have no control over what happens to it after that - you can't force the browser to save it, or say where it should be saved if the user chooses to do that.
Share this answer
.net developer123456789 8-Apr-19 5:00am    
Thanks OriginalGriff,

I tired following code but can't work on Visual Basic.

Dim DownloadedFileFilename As String ' you save here your downloaded file name
Dim EA As Excel.Application
Dim DownloadedFile As Workbook

Set EA = New Excel.Application
With EA
.Visible = True ' Just to make sure
.ScreenUpdating = True ' Just to make sure
Set DownloadedFile = .Workbooks.Open(Filename:=DownloadedFileFilename), ReadOnly:=True)
End With

any idea ?
how to download .xlsx file in internet explorer dialog box using visual basic
OriginalGriff 8-Apr-19 5:07am    
Why would you think that would do anything useful?
It's VB code: it runs on the server. It requires the server to have Excel installed, and it will display on the server, not the client.
It might do something in development where they are the same machine, but it won't work in production ... and you cannot start any app on the Client computer directly from the server for security reasons.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900