Results 1 to 4 of 4

Thread: [RESOLVED] [2005] Get folder names only within specific directory?

Threaded View

  1. #1

    Thread Starter
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Resolved [RESOLVED] [2005] Get folder names only within specific directory?

    The idea is that people enter their surname into a text box and press a button which searches for username folders contained within the Surname directory. This works but displays the full path of the immediate folders contained within the Surname directory. I know there is a GetFileNameOnly function. Is there something similar for folders? If not, what's my best way to do this? Pre-process the string before adding it by searching for characters after the last \ character?

    VB Code:
    1. Dim frmFinish As New frmAboutBox
    2.         If System.IO.Directory.Exists(Application.StartupPath & "\User Accounts\" & txtRemindSurname.Text & "\") Then
    3.             Dim Count As Integer = System.IO.Directory.GetDirectories _
    4.             (Application.StartupPath & "\User Accounts\" & txtRemindSurname.Text & "\").Length
    5.             Select Case Count
    6.                 Case Is >= 2
    7.                     MessageBox.Show("There are " & Count & " directories with that surname. Please select from below " _
    8.                     & "from the list which username you would like to recover the password for.", "Count2", MessageBoxButtons.OK)
    9.                     For Each FolderName As String In System.IO.Directory.GetDirectories _
    10.                     (Application.StartupPath & "\User Accounts\" & txtRemindSurname.Text & "\")
    11.  
    12.                         lbxUserNames.Items.Add(FolderName)   'Adds full path, how do I get only
    13.                     Next                                     'folder names within the  UserAccounts/Surname/ directory?
    14.                 Case Is = 1
    15.                     'Load single username into listbox
    16.                     'Blah
    17.                     'Blah
    18.                 Case Else
    19.                     MessageBox.Show("Not enough folders to examine. More users needed", "Insufficient Users", MessageBoxButtons.OK)
    20.                     frmFinish.Show()
    21.                     Me.Hide()
    22.             End Select
    23.         End If
    Last edited by stimbo; Oct 2nd, 2006 at 10:40 AM.

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