Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
here in the below coding i got the filenames displayed in the listbox, but i need the option for selecting .doc or .rtf which is to in dropdown in text box by selecting the selected fileformats to be displayed in the textbox.........

VB
Using flb As New FolderBrowserDialog
           If flb.ShowDialog() = Windows.Forms.DialogResult.OK Then
               ListBox1.Items.Clear()
               TextBox1.Text = flb.SelectedPath
               Dim fileNames As String() = Directory.GetFiles(flb.SelectedPath)
               Dim selectedFiles As String() = From fileName In fileNames Where fileName.EndsWith(".rtf") Or fileName.EndsWith(".doc") Select fileName
               For Each filename In selectedFiles
                   ListBox1.Items.Add(filename)
               Next
           End If
       End Using
Posted
Comments
Wayne Gaylard 11-Nov-11 9:21am    
Please reword your question, as it doess not make sense as to what you are tryin to do

1 solution

Use the two-string overload of the directory.GetFiles method: MSDN[^]
The second string allows you to only retrieve the files which match a selection string ("*.rtf" or "*.doc")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900