gpt4 book ai didi

vb.net-2010 - 在 vb.net 中显示文件夹/文件中的图像

转载 作者:行者123 更新时间:2023-12-04 11:25:24 25 4
gpt4 key购买 nike

Dim ImagePath As String = "images/spaceship2.png"
Dim img1 As Bitmap
Dim newImage As Image = Image.FromFile("images/spaceship2.png")

img1 = New Bitmap(ImagePath)
pb2.ImageLocation = ImagePath

pb1.Image = newImage

我想显示文件夹中的图像,例如,id 号为 22137471 的学生,名称为 22137471 的图片将显示在我的图片框中,之间,我在谷歌的某个地方看到了这段代码。

最佳答案

i want to display image from folder, for example, student with an idnumber of 22137471, the picture with the name of 22137471 will bedisplay on my picture box


尝试类似...
Dim id As String = "22137471"
Dim folder As String = "c:\some path\folder"
Dim filename As String = System.IO.Path.Combine(folder, id & ".png")
PictureBox1.Image = Image.FromFile(filename)
这是一个不锁定原始图像文件的更新版本:
Dim id As String = "22137471"
Dim folder As String = "c:\some path\folder"
Dim filename As String = System.IO.Path.Combine(folder, id & ".png")
Try
Using fs As New System.IO.FileStream(filename, IO.FileMode.Open)
PictureBox1.Image = New Bitmap(Image.FromStream(fs))
End Using
Catch ex As Exception
Dim msg As String = "Filename: " & filename &
Environment.NewLine & Environment.NewLine &
"Exception: " & ex.ToString
MessageBox.Show(msg, "Error Opening Image File")
End Try

关于vb.net-2010 - 在 vb.net 中显示文件夹/文件中的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19748868/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com