I was trying to save multiple image to a local folder in one go in vb. Right now, i am able to save one image at a time to a specified folder. In my code, i have set up a file name for the image to use when uploaded. What I needed is to save the image with it's original file name and file type. My program should also allow user to save multiple images in one go.
I am Using VB 2013 Ultimate
this is the code for searching.
Try a.Filter = "Image files | *.*" If a.ShowDialog() = Windows.Forms.DialogResult.OK Then PictureBox1.Image = Image.FromFile(a.FileName) PictureBox1.BackgroundImageLayout = ImageLayout.Stretch End If Catch ex As Exception MsgBox(ex.Message) End Try
If (Not System.IO.Directory.Exists("d:/Site Images/" & Label33.Text & "/")) Then System.IO.Directory.CreateDirectory("d:/Site Images/" & Label33.Text & "/") End If 'Dim address = ("d:/Site Images/" & a.FileName & ".jpg") PictureBox1.Image.Save("d:/Site Images/" & Label33.Text & "/" & "a.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
thanks for the help.
A sample snippet
Dim a As New OpenFileDialog
a.Filter = "Jpeg Files|*.jpg"
a.ShowDialog()
For i As Integer = 0 To a.FileNames.Count - 1
Try
Dim img As Image = Image.FromFile(a.FileNames(i))
img.Save("Your Saving Path")
Catch ex As Exception
End Try
Next
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.