Solved

DISPLAYING SUB DIRECTORIES ON WIN FORM IN VB NET

Posted on 2006-06-20
1
198 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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now