After much reading of many many post here and the help files in VB express, I have the following codes and would like to know if you think the 'directory' and 'file' methods are better than the 'directoryinfo' and 'fileinfo' I used.
Also, I tried to update the lblTotalFiles and lstFullNames as I stepped through but instead it waited until the end and populated all at once. Why is that?
VB Code:
Imports System Imports System.IO Imports Microsoft.VisualBasic.ControlChars Imports System.Windows.Forms Public Class frmMain Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click Dim sPath As String = "" Dim fbdPath As New FolderBrowserDialog() fbdPath.ShowDialog() With fbdPath sPath = .SelectedPath lblInitPath.Text = .SelectedPath.ToString MsgBox(sPath) End With GatherFiles(sPath) End Sub Private Sub GatherFiles(ByVal sFilePath As String) Dim instance As New DirectoryInfo(sFilePath) Dim returnValue As FileInfo Dim intValue As Integer = 0 For Each returnValue In instance.GetFiles("*.pdf", IO.SearchOption.AllDirectories) lstFullNames.Items.Add(returnValue.FullName) intValue = intValue + 1 Next returnValue lblTotalFiles.Text = intValue.ToString End Sub End Class




Reply With Quote