CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2008
    Posts
    3

    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?

  2. #2
    Join Date
    Aug 2004
    Location
    Mumbai,INDIA
    Posts
    144

    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.
    Ritik D Dodhiwala
    Software Devloper
    Mumbai,India
    [IF MY SUGGESTIONS WORKS POSITIVLY PLEASE RATE POSITIVLY ]

  3. #3
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Saving a picture from a web site

    More likely it's still loaded in the browser. Close all browser windows.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  4. #4
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    516

    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

  5. #5
    Join Date
    Jan 2008
    Posts
    3

    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!

  6. #6
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    516

    Re: Saving a picture from a web site

    Ahhhh... Didn't notice you were using .NET. Glad it worked for you.

  7. #7
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    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....
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured