title: Saving an Image in VB.NET
body: <p>I have a little code for saving an image from an URL in VB.NET but im not finding the location where it saves the image, i added a location string but i dont know how to use it in the code.
  How do i change the location whre my code saves the    image ( Imports System.Drawing
  Public Class Form1)</p>
  
  <pre><code>Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  
  End Sub
  
  Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
      Dim MyImage As System.Drawing.Image
      Dim URL As String = TextBox1.Text
      Dim FileName As String, URLpieces As String()
      Dim location As String = "C:/SaveIMGURL/"
      URLpieces = Split(URL, "/")
      FileName = URLpieces.GetValue(UBound(URLpieces))
      MyImage = GetImage(URL)
      MyImage.Save(FileName)
      MyImage = Nothing
  End Sub
  Function GetImage(ByVal URL As String) As System.Drawing.Image
      Dim Request As System.Net.HttpWebRequest
      Dim Response As System.Net.HttpWebResponse
      Request = System.Net.WebRequest.Create(URL)
      Response = CType(Request.GetResponse, System.Net.WebResponse)
      If Request.HaveResponse Then
          If Response.StatusCode = Net.HttpStatusCode.OK Then
              GetImage = System.Drawing.Image.FromStream(Response.GetResponseStream)
          End If
      End If
      Try
      Catch e As System.Net.WebException
          MsgBox("A web exception has occured [" &amp; URL &amp; "]." &amp; vbCrLf &amp; " System returned: " &amp; e.Message, MsgBoxStyle.Exclamation, "Error!")
          Exit Try
      Catch e As System.Net.ProtocolViolationException
          MsgBox("A protocol violation has occured [" &amp; URL &amp; "]." &amp; vbCrLf &amp; "  System returned: " &amp; e.Message, MsgBoxStyle.Exclamation, "Error!")
          Exit Try
      Catch e As System.Net.Sockets.SocketException
          MsgBox("Socket error [" &amp; URL &amp; "]." &amp; vbCrLf &amp; "  System returned: " &amp; e.Message, MsgBoxStyle.Exclamation, "Error!")
          Exit Try
      Catch e As System.IO.EndOfStreamException
          MsgBox("An IO stream exception has occured. System returned: " &amp; e.Message, MsgBoxStyle.Exclamation, "Error!")
          Exit Try
      Finally
      End Try
  End Function
  </code></pre>
  
  <p>End Class</p>