trying to get around the "File Download" dialog box in internet explorer
When you click on a file in internet explorer (file.exe for example) then the "File Download" dialog box comes up. I have a webbrowser control in my program, and when people click on "file.exe" then I don't want the "file download" dialog to appear, I just want it to automatically download to the desktop. An input box that says "Are you sure you want to download 'file.exe'?" would be better, but If you tell me the first thing then I can add the inputbox after.
Thanks in advance.
Re: trying to get around the "File Download" dialog box in internet explorer
I copied the code above and the event filedownload dosen't fire
:confused:
what's wrong???
Re: trying to get around the "File Download" dialog box in internet explorer
Re: trying to get around the "File Download" dialog box in internet explorer
VB Code:
Private Declare Function DoFileDownload Lib "shdocvw.dll" (ByVal lpszFile As String) As Long
Private Sub Form_Load()
DoFileDownload StrConv("http://www.server.com/download/file.zip", vbUnicode)
End Sub
Re: trying to get around the "File Download" dialog box in internet explorer
@foxter: You are aware that this thread was 5 years old, aren't you? :)
Re: trying to get around the "File Download" dialog box in internet explorer
People dont [RESOLVE] the thread, and dont post the answer they got. How do you think other people will get the answer? Do others need to ask again the same question? I'd rather post the solution, so others would have it, no matter how old the problem is.
Re: trying to get around the "File Download" dialog box in internet explorer
Well, 5 years ago it wasn't as common for people here to put the word "RESOLVED" in the title. Besides, using DoFileDownload as you suggested does not "get around the 'File Download' dialog box" which was the origional question. Using URLDownloadToFile as I suggested in post #2 above (5 years ago) would however do that. :)
Re: trying to get around the "File Download" dialog box in internet explorer
Also, Cancel = True doesn't prevent the normal download dialog box from appearing. Don't even know what it's purpose is. However, the code for something like this should be placed in the _BeforeNavigate2 event because there Cancel = True will prevent the download box from popping up.
Re: trying to get around the "File Download" dialog box in internet explorer
This will bypass the dialog box:
Add reference to WinHTTP.dll in systems32. (Browse to it, if Microsoft WinHTTP services doesn't show on the references list.)
Note this simple example doesn't do anything fancy, just dumps the downloaded bytes to disk.
OnResponseStart when you can safely access the headers.
OnResponseDataAvailable which returns a byte array of downloaded data for each chunk.
OnResponseEnd which ends the download.
Code:
Option Explicit
Private WithEvents http As WinHttpRequest
Private mContentLength As Long
Private mProgress As Long
Private Sub Command1_Click()
' Create the WinHTTPRequest ActiveX Object.
Set http = New WinHttpRequest
' Open an HTTP connection.
http.open "GET", "http://home.in.tum.de/~paula/mpeg/wg_gdo_1.mpg", True 'True means asynch.
' Send the HTTP Request.
http.send
End Sub
Private Sub http_OnResponseDataAvailable(Data() As Byte)
mProgress = mProgress + UBound(Data) + 1
ProgressBar1.Value = mProgress
Put #1, , Data
End Sub
Private Sub http_OnResponseFinished()
Close #1
MsgBox "done"
End Sub
Private Sub http_OnResponseStart(ByVal Status As Long, ByVal ContentType As String)
Text1.Text = http.getAllResponseHeaders()
mProgress = 0
mContentLength = CLng(http.getResponseHeader("Content-Length"))
ProgressBar1.Max = mContentLength
Open "C:\twg_gdo_1.mpg" For Binary As #1
End Sub
Re: trying to get around the "File Download" dialog box in internet explorer
This will bypass the dialog box:
What dialog box are you refering to?
Re: trying to get around the "File Download" dialog box in internet explorer
Quote:
Originally Posted by jmsrickland
This will bypass the dialog box:
What dialog box are you refering to?
The ie download dialog