asp.net

Asked By kshama parashar
01-Sep-10 06:54 AM
Earn up to 0 extra points for answering this tough question.
how to save image in a directory in vb.net window application

  re: asp.net

Reena Jain replied to kshama parashar
01-Sep-10 07:48 AM
hi

here is the code for you

Private Sub browse_butt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles browse_butt.Click

      'TextBox1 as string = ""

      'Image.Title = "Set Image File"

      Image.Filter = "Jpeg files (*.jpeg)|*.jpg|All files (*.*)|*.*"

      Image.DefaultExt = "jpeg"

      Image.FilterIndex = 1

      Image.FileName = ""

      Image.ShowDialog()




      sFilePath = Image.FileName

      TextBox1.Text = sFilePath


      'string DefaultExt = Path.GetExtension(FileName);
      imageFile = TextBox1.Text
    


    End Sub

    Private Sub clear_butt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clear_butt.Click
      TextBox1.Text = ""
    End Sub

    Private Sub sub_butt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sub_butt.Click
      ''Dim fs As FileStream = New FileStream(TextBox1.ToString(), FileMode.Open)

      ''Dim img As Byte() = New Byte(fs.Length) {}

      ''fs.Read(img, 0, fs.Length)

      ''fs.Close()

      ''imageFile = Image.FromFile(TextBox1.ToString())

      'Dim strConnect As String

      'strConnect = "Data Source=bxswlt;Initial Catalog=ImageGallery;User ID=sa"

      'Dim conn As MySqlConnection = New MySqlConnection(strConnect)



      'Dim sSQL As String = "UPDATE coordinate SET lakaran_kejadian VALUES (@TextBox1)"

      ''UPDATE `accidentdata2006`.`accident_info` SET `lakaran_kejadian` =

      'Dim cmd As SqlCommand = New SqlCommand(sSQL, conn)


      Dim sSavePath As String
      sSavePath = "images/"

      Dim pic As Image
      'imageFile = Image.f


      Dim fileName As String = Image.FileName.ToString()
      'Dim userName As String = Profile.UserName
      Dim uploadFolderPath As String = "~/upload/"
      Dim filePath As String = HttpContext.Current.Server.MapPath(uploadFolderPath)
      'Directory.CreateDirectory(filePath + "\" + userName)

  re: asp.net

Super Man replied to kshama parashar
01-Sep-10 08:23 AM

This works in windows application.

Above code by @reena work for website

 

 

      'here assumed that you have image named as i

      Dim i As Image

 

      ' here set direcory as you want

      Dim Dir_path As String = "c:\hello\"

 

      'set imagename as you want

      Dim image_name As String = "hello.jpg"

 

      ' saves image

      i.Save(Dir_path + image_name)

Create New Account