Dear good afternoon, I hope someone can help me, I have a form which shows images in a PictureBox control that are in a certain path of my pc, and they are changed every so often as a SlideShow .. what I want to do with this and I can not think of how .. is to put in a Timer control with a While statement, or Do While, that is checking the total weight of the files in the folder, and that when it resizes, it will reload the code with the new images that have been added ... I attach my code:
Private Sub Panel_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim con As New SqlConnection
Dim cmd As New SqlCommand
con.ConnectionString = "Data Source=Server;Initial Catalog=panelinfo;User ID=sa; Password=123456;"
con.Open()
cmd.Connection = con
cmd.CommandText = "SELECT ubicacion FROM fotos"
Dim lrd As SqlDataReader = cmd.ExecuteReader()
If lrd.Read() Then
lblSlideRuta.Text = lrd("ubicacion")
End If
con.Close()
If lblSlideRuta.Text <> "" Then
Dim di As New IO.DirectoryInfo(lblSlideRuta.Text)
ImageDir = di.GetFiles("*.jpg").Concat(di.GetFiles("*.bmp")).Concat(di.GetFiles("*.png")).Concat(di.GetFiles("*.gif")).ToArray
Dim dra As IO.FileInfo
frm = New Form
frm.Name = "frm"
FullSizePic = New PictureBox
FullSizePic.Dock = DockStyle.Fill
FullSizePic.BackColor = Color.Black
FullSizePic.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
PicBoxImagenes.Controls.Add(FullSizePic)
AddHandler frm.KeyDown, AddressOf frm_keydown
'frm.Show()
TimerSlide.Enabled = True
'EnterFullScreen(frm)
GetnextImage()
End If
End Sub
Private Sub GetnextImage()
If Not ImageDir Is Nothing Then
If ImageIndex < ImageDir.Length - 1 Then
ImageIndex += 1
FullSizePic.ImageLocation = ImageDir(ImageIndex).FullName
ElseIf ImageIndex = ImageDir.Length - 1 Then
ImageIndex = 0
FullSizePic.ImageLocation = ImageDir(ImageIndex).FullName
End If
End If
End Sub