Código
Imports System.IO Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim ExtensionBuscada As String = "*.txt" Dim dirInfo As New DirectoryInfo(TextBox1.Text) Dim dirsInfo() As DirectoryInfo = dirInfo.GetDirectories("*.*", SearchOption.TopDirectoryOnly) For Each di As DirectoryInfo In dirsInfo Try Dim filesInfo() As FileInfo = di.GetFiles(ExtensionBuscada, SearchOption.AllDirectories) For Each fichero As FileInfo In filesInfo ListBox1.Items.Add(fichero.FullName) Label6.Text = ListBox1.Items.Count Next Catch ex As UnauthorizedAccessException ' Controlo el error de acceso no autorizado a carpeta End Try Next End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Timer1.Start() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Me.ListBox1.SelectedIndex = 0 Button2_Click(sender, e) End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If ListBox1.Items.Count > 0 Then Label6.Text = ListBox1.Items.Count Me.ListBox1.SelectedIndex = 0 Label1.Text = ListBox1.SelectedItem.ToString Label7.Text = Val(Label7.Text) + Val("1") Me.DATOSTableAdapter.Insert(Label7.Text, Label1.Text, Label3.Text, Label4.Text, Label5.Text) 'INSERTAR NUEVO DATOS ListBox1.Items.Remove(ListBox1.SelectedItem) Else Label6.Text = ListBox1.Items.Count Me.DATOSTableAdapter.Fill(Me.CAPTURADataSet.DATOS) Timer1.Stop() End If Private Sub DATOSBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DATOSBindingNavigatorSaveItem.Click Me.Validate() Me.DATOSBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.CAPTURADataSet) End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'TODO: esta línea de código carga datos en la tabla 'CAPTURADataSet.DATOS' Puede moverla o quitarla según sea necesario. Me.DATOSTableAdapter.Fill(Me.CAPTURADataSet.DATOS) End Sub End Class
Si funciona, agrega bien pero en cierto tiempo de que agrego algunos detiene la depuración marca error en la linea de agregar a la bd.
Código
Me.DATOSTableAdapter.Insert(Label7.Text, Label1.Text, Label3.Text, Label4.Text, Label5.Text) 'INSERTAR NUEVO DATOS