|
-
Oct 5th, 2009, 11:18 PM
#1
Thread Starter
Fanatic Member
Downloading Image to Hard Disk Using Webbrowser control
Is there away to do so?
Does htmlimg object contain the binary data of the image somewhere?
I can use URLdownloadtofile API but that means I am bypassing internetexplorer proxy
I want to download file through internet explorer
-
Oct 6th, 2009, 12:38 AM
#2
Re: Downloading Image to Hard Disk Using Webbrowser control
If it's showing in the browser, then it's already downloaded to your computer. IE saves images and stuff to a temporary/cache folder. You may have to figure out the path it saves to and copy it to another folder.
-
Oct 6th, 2009, 05:29 AM
#3
Thread Starter
Fanatic Member
Re: Downloading Image to Hard Disk Using Webbrowser control
Okay. I have to figure out the path and copy it to another folder. The question is how?
Anyone knows? I need ways that work both for vb6 and vb.net
-
Oct 6th, 2009, 06:04 AM
#4
Re: Downloading Image to Hard Disk Using Webbrowser control
C:\Documents and Settings\WINDOWS_USERNAME\Local Settings\Temporary Internet Files
That's the folder for me. I went to Google and then opened that folder and saw the logo.gif file. The name of the file is the same as it appears in the webpage. I'm pretty sure it's just a shortcut, though.
Maybe someone else knows more about this, I don't really have the time at the moment to try.
-
Oct 6th, 2009, 06:11 AM
#5
Thread Starter
Fanatic Member
Re: Downloading Image to Hard Disk Using Webbrowser control
Interesting. The name of the file is the same with the name of the appearingin webpage.
Is there a way to know the location of C:\Documents and Settings\WINDOWS_USERNAME\Local Settings\Temporary Internet Files automatically or programatically?
This seems to be a good enough solution.
Last edited by teguh123; Oct 6th, 2009 at 06:20 AM.
-
Oct 6th, 2009, 07:12 AM
#6
Re: Downloading Image to Hard Disk Using Webbrowser control
I would use SHGetSpecialFolderLocation
I found this, only skimmed through it quickly. It might have what you need:
http://www.vbforums.com/showthread.php?t=99951
-
Oct 6th, 2009, 10:01 AM
#7
Frenzied Member
Re: Downloading Image to Hard Disk Using Webbrowser control
Just so you know, when you use the URLDownloadToFile API, if the file exists it will copy that file from the cache for you and not use more bandwidth (or so it seems to me when I use it in conjunction with the webbrowser control). Give it a test...
Good Luck
Option Explicit should not be an Option!
-
Oct 6th, 2009, 09:53 PM
#8
Thread Starter
Fanatic Member
Re: Downloading Image to Hard Disk Using Webbrowser control
So if the file exist it'll get that from internet explorer cache and if it doesn't it'll download?
Actually I do use urldownloadtofile API. The cache is definetely there but the download just fail. The download doesn't fail if IE do not use proxy.
I think urldownloadtofile does use a cahce, but it's a different cache than the one internet explorer use.
Can anyone confirm this?
Let me check.
Last edited by teguh123; Oct 6th, 2009 at 10:06 PM.
-
Oct 7th, 2009, 04:14 AM
#9
Re: Downloading Image to Hard Disk Using Webbrowser control
it is also possible to copy and paste images from the webbrowser itself, there was a thread on that recently
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 7th, 2009, 11:47 AM
#10
Thread Starter
Fanatic Member
Re: Downloading Image to Hard Disk Using Webbrowser control
Oh really.
That would be the best way. How? I've been looking for it.
-
Oct 7th, 2009, 03:21 PM
#11
Re: Downloading Image to Hard Disk Using Webbrowser control
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 11th, 2009, 04:41 AM
#12
Thread Starter
Fanatic Member
Re: Downloading Image to Hard Disk Using Webbrowser control
Okay, I used SHGetSpecialFolderLocation. I manage to get the name of the file.
However, it seems that it's not a regular file. If I double click it will open firefox rather than regular image.
Also fileExist(theFile) where
Public Function fileExist(filename As String) As Boolean
Dim fso As FileSystemObject
Set fso = New FileSystemObject
fileExist = fso.FileExists(filename)
End Function
will produce false.
so the file is C:\Documents and Settings\Ferry\Local Settings\Temporary Internet Files\thefile.jpg which is correct. But it'll produce false as if there is no such file.
Hmm.... Any other alternative?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|