471,594 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,594 software developers and data experts.

Any controls for Folder selection Not File. When I click "Browse"

Hello VB Developers....


I like to select a folder, by clicking a button.

I am using common dialog box for this. But it selects only file.

Also I need code to list of xml file to list into list box contains the selected folder.

Thanks.
vishwa Ram.
Jun 2 '07 #1
1 1324
You need to be more specific with your help questions. State whether you're using VB6 or .NET, not just what you want to do. It's real easy to do it in .NET:

Expand|Select|Wrap|Line Numbers
  1.         'set the folder browser
  2.         Dim folderBrowser As New FolderBrowserDialog
  3.  
  4.         'open the dialog and if the user presses OK...
  5.         If folderBrowser.ShowDialog And Windows.Forms.DialogResult.OK Then
  6.  
  7.             'set the directory info for the selected folder
  8.             Dim dirInfo As New System.IO.DirectoryInfo(folderBrowser.SelectedPath)
  9.  
  10.             'clear the listbox
  11.             ListBox1.Items.Clear()
  12.  
  13.             'iterate through the files in the selected folder...
  14.             For i As Integer = 0 To dirInfo.GetFiles.Length - 1
  15.                 'if the extension is xml...
  16.                 If LCase(System.IO.Path.GetExtension(folderBrowser.SelectedPath & "\" & _
  17.                 dirInfo.GetFiles.GetValue(i))) = ".xml" Then
  18.                     'list them in the listbox
  19.                     ListBox1.Items.Add(dirInfo.GetFiles.GetValue(i))
  20.                 End If
  21.             Next
  22.         End If
  23.  
I hope that's what you're looking for. Reply if it works or not.
Jun 3 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by laredotornado | last post: by
9 posts views Thread by Roger Withnell | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.