Solved

DISPLAYING SUB DIRECTORIES ON WIN FORM IN VB NET

Posted on 2006-06-20
1
232 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

839 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