View Poll Results: Are these codes written in good programming format?

Voters
2. You may not vote on this poll
  • Yes

    0 0%
  • No

    0 0%
  • kind of

    2 100.00%
  • I don't know

    0 0%
Multiple Choice Poll.
Results 1 to 5 of 5

Thread: [2005] File Search Questions

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2006
    Posts
    28

    Arrow [2005] File Search Questions

    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:
    1. Imports System
    2. Imports System.IO
    3. Imports Microsoft.VisualBasic.ControlChars
    4. Imports System.Windows.Forms
    5.  
    6. Public Class frmMain
    7.  
    8.     Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click
    9.         Dim sPath As String = ""
    10.         Dim fbdPath As New FolderBrowserDialog()
    11.         fbdPath.ShowDialog()
    12.  
    13.         With fbdPath
    14.             sPath = .SelectedPath
    15.             lblInitPath.Text = .SelectedPath.ToString
    16.             MsgBox(sPath)
    17.         End With
    18.         GatherFiles(sPath)
    19.     End Sub
    20.  
    21.     Private Sub GatherFiles(ByVal sFilePath As String)
    22.  
    23.         Dim instance As New DirectoryInfo(sFilePath)
    24.         Dim returnValue As FileInfo
    25.         Dim intValue As Integer = 0
    26.  
    27.  
    28.         For Each returnValue In instance.GetFiles("*.pdf", IO.SearchOption.AllDirectories)
    29.             lstFullNames.Items.Add(returnValue.FullName)
    30.             intValue = intValue + 1
    31.         Next returnValue
    32.         lblTotalFiles.Text = intValue.ToString
    33.  
    34.     End Sub
    35.  
    36. End Class
    Last edited by RobDog888; Nov 30th, 2006 at 06:36 PM. Reason: Added [vbcode] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width