Saving a picture from a web site
I tried to move the file from the Temporary Internet Files folder but access is restricted.
Code:
My.Computer.FileSystem.CopyFile(TempPath & filename, StartPath & "\Saved")
picture boxes are are also restricted from the TIF directory.
I am able to get the URL of the picture but still havent had success in saving the image.
Does anyone know how to go about doing this?
Re: Saving a picture from a web site
Quote:
Originally Posted by Reveille
I tried to move the file from the Temporary Internet Files folder but access is restricted.
Code:
My.Computer.FileSystem.CopyFile(TempPath & filename, StartPath & "\Saved")
picture boxes are are also restricted from the TIF directory.
I am able to get the URL of the picture but still havent had success in saving the image.
Does anyone know how to go about doing this?
Check may be file is read only.
Re: Saving a picture from a web site
More likely it's still loaded in the browser. Close all browser windows.
Re: Saving a picture from a web site
If you have the URL, just get your own copy with the URLDownloadToFile API.
Code:
Private Declare Function URLDownloadToFile Lib "urlmon.dll" Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, _
ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private Sub TryThis()
Dim sURL As String, sTarget As String
sURL = "http://somewebsite.com/somepicture.jpg"
sTarget = "C:\SomeFolder\somepicture.jpg"
Call URLDownloadToFile(0, sURL, sTarget, 0, 0)
End Sub
Re: Saving a picture from a web site
Comintern, you are my saviour.
I had to change the parameters from Long to Integer because it was "destabilizing the stack" o.O but other than that it worked like a charm.
THANK YOU!
Re: Saving a picture from a web site
Ahhhh... Didn't notice you were using .NET. Glad it worked for you.
Re: Saving a picture from a web site
Quote:
Originally Posted by Comintern
Ahhhh... Didn't notice you were using .NET. Glad it worked for you.
Then this post is in the wrong forum.... ;)