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:
Dim frmFinish As New frmAboutBox If System.IO.Directory.Exists(Application.StartupPath & "\User Accounts\" & txtRemindSurname.Text & "\") Then Dim Count As Integer = System.IO.Directory.GetDirectories _ (Application.StartupPath & "\User Accounts\" & txtRemindSurname.Text & "\").Length Select Case Count Case Is >= 2 MessageBox.Show("There are " & Count & " directories with that surname. Please select from below " _ & "from the list which username you would like to recover the password for.", "Count2", MessageBoxButtons.OK) For Each FolderName As String In System.IO.Directory.GetDirectories _ (Application.StartupPath & "\User Accounts\" & txtRemindSurname.Text & "\") lbxUserNames.Items.Add(FolderName) 'Adds full path, how do I get only Next 'folder names within the UserAccounts/Surname/ directory? Case Is = 1 'Load single username into listbox 'Blah 'Blah Case Else MessageBox.Show("Not enough folders to examine. More users needed", "Insufficient Users", MessageBoxButtons.OK) frmFinish.Show() Me.Hide() End Select End If




Reply With Quote