Solved

DISPLAYING SUB DIRECTORIES ON WIN FORM IN VB NET

Posted on 2006-06-20
1
237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 86

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
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.
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

726 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