Solved

DISPLAYING SUB DIRECTORIES ON WIN FORM IN VB NET

Posted on 2006-06-20
1
225 Views
Last Modified: 2010-04-23
i WANT TO DISPLAY IN A LISTBOX ALL THE SUB DIRECTORIES IN A DIRECTORY ON FORM OPEN. tHIS IS TO BE DONE IN WIN FORMS OF VB NET
0
Comment
Question by:abobby2005
1 Comment
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 125 total points
ID: 16946190
Something like...

Public Class Form1
    Inherits System.Windows.Forms.Form

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        DisplayFolders(ListBox1, "c:\some\Folder\path")
    End Sub

    Private Sub DisplayFolders(ByVal lb As ListBox, ByVal parentFolder As String)
        Try
            Dim di As New System.IO.DirectoryInfo(parentFolder)
            If di.Exists Then
                lb.BeginUpdate()
                lb.Items.Clear()
                lb.Items.AddRange(di.GetDirectories)
                lb.EndUpdate()
            Else
                MessageBox.Show("parentfolder = " & parentFolder, "Path Not Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message & vbCrLf & "parentfolder = " & parentFolder, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

End Class
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
vb.net 2 44
Call windows 10 virtual keyboard from windows forms app 2 36
export data table to excel in vb.net 10 27
ASP/VB email question 4 35
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question