循环文件扩展名

时间:2016-08-23 17:05:14

标签: vb.net file loops picturebox

Try
    Dim lImage As Image = Image.FromFile(appPath + "\" + "ActiveDisplay" + "\" + "Helmets" + "\" + vData + **"extension loop need"**)
    ResizePicture(Me.PictureBox1, lImage)
Catch ex As Exception

End Try

我正在查看器中搜索图像名称,需要循环扩展 任何帮助将不胜感激

1 个答案:

答案 0 :(得分:0)

您可以使用String数组和For Each

    Dim extensions As String() = {".png", ".jpg", ".bmp"}
    For Each ext As String In extensions
        Dim file As String = appPath + "\" + "ActiveDisplay" + "\" + "Helmets" + "\" + vData + ext

        'I recomend use:  Dim file As String= String.Format("{0}\ActiveDisplay\Helmets\{1}\{2}", appPath, vData, ext)

        If IO.File.Exists(file) Then
            Dim lImage As Image = Image.FromFile(file)
        End If
    Next