anybody know how to save picture in picture box after upload and set picture witdh+heigh size. i want same picture in picturebox after i relaunch application .. i use this code to upload picture into picturebox....please anybody

Dim OpenFileDialog1 As New OpenFileDialog


        With OpenFileDialog1
            .CheckFileExists = True
            .ShowReadOnly = False
            .Filter = "All Files|*.*|Bitmap Files (*)|*.bmp;*.gif;*.jpg"
            .FilterIndex = 2
            If .ShowDialog = DialogResult.OK Then
                ' Load the specified file into a PictureBox control.
                PictureBox1.Image = Image.FromFile(.FileName)
            
               
            End If
        End With

Edited 5 Years Ago by __avd: Added [code] tags.

See if this helps.
1 PictureBox, 1 Button

Public Class Form1
    Private myCoolFile As String = "C:\test.txt" '// File to save/load FullPath of Image.

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        '// Save File if there is a FullPath in the .Tag.
        If Not PictureBox1.Tag Is Nothing Then IO.File.WriteAllText(myCoolFile, PictureBox1.Tag.ToString)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize '// Resize PictureBox by Image Size.
        If IO.File.Exists(myCoolFile) Then '// check if File.Exists.
            Dim sTemp As String = IO.File.ReadAllText(myCoolFile) '// read File content, which should only be the image location of last image loaded.
            If IO.File.Exists(sTemp) Then '// check if last image path saved .Exists.
                PictureBox1.Image = Image.FromFile(sTemp) '// Load image in PictureBox.
                PictureBox1.Tag = sTemp '// set .Tag to image's FullPath.
            End If
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim OpenFileDialog1 As New OpenFileDialog
        With OpenFileDialog1
            .CheckFileExists = True
            .ShowReadOnly = False
            .Filter = "All Files|*.*|Bitmap Files (*)|*.bmp;*.gif;*.jpg;*.png"
            .FilterIndex = 2
            If .ShowDialog = DialogResult.OK Then
                PictureBox1.Image = Image.FromFile(.FileName) '// Load image.
                PictureBox1.Tag = .FileName '// keep FullPath of image for saving to file.
            End If
        End With
    End Sub
End Class

Edited 5 Years Ago by codeorder: n/a

This question has already been answered. Start a new discussion instead.