Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I've run into a bit of a problem :( I'm trying to download selected files from an arbitrary web page. The image files are to be written to a directory.

 

private local as string = "./images"

Dim FileStreamer As New FileStream(local, FileMode.Create)

 

now I have tryed this but I'm getting a error indicatiing that I don't have permission? This is wierd as if I pass in a location to my method the code works fine. Anyone got some advice or a nice reference site?

  • Moderators
Posted

Here's a function that works for me..

 

   Private Sub GetImage(ByVal sDir As String, ByVal sName As String)
       Try
           Dim wc As New Net.WebClient()
           wc.DownloadFile(URL_IMAGE & sDir & "/" & sName, sName)
           wc.Dispose()
           Image1.Image = Image.FromFile(s)'display it in an image box
       Catch ex As Exception
           Throw New Exception(ex.Message)
       End Try
   End Sub
'URL_IMAGE is the web server location
'sDir is the directory it's in
'sName the name of the pic

Visit...Bassic Software
Posted

cheers I'll try and use that code if I can :) I do have one other question though that someone may be able to answer:

 

Reqest = HttpWebRequest.Create(sURL & Filename & Prefix)

 

if I want to use the above code...where sURL is a URI is there a way to add the filename and prexif to the URI. Sorry if it a basic question but this is day two of web stuff :(

 

 

Thanx

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...