• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 438
  • Last Modified:

CheckedLISTBOX > Load folder/Dir names (vb.net 2010 exp)

Hi Experts,

I'm trying to build a winform app with:
1. CheckedListBox1
1. WebBrowser1

on "Form1_Load", I want to load folder names form a specific directory into my CheckedListBox1.
if I check the foldername e.g. FolderA, it will load "FolderA\FolderA.html" into my WebBrowser1.

If asked similar questions regarding files in the past, but cannot adapt :(

Thanks,
Roberto
Private sourceFolder As String = "C:\sourcefolder\"
    Dim di As New DirectoryInfo(sourceFolder)


 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadFiles()
    End Sub


Private Sub CheckedListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckedListBox1.SelectedIndexChanged
        If Not (CheckedListBox1.SelectedItem Is Nothing) Then
            WebBrowser1.Navigate("C:\sourcefolder\")
        End If

Open in new window

0
RobertoFreemano
Asked:
RobertoFreemano
  • 3
2 Solutions
 
RobertoFreemanoAuthor Commented:
Ok, this lists dir's but I'd like to only show names & not full path.

Also: click event
ListBox1.Items.AddRange(IO.Directory.GetFiles("c:\sourcefolder"))

Open in new window

0
 
käµfm³d 👽Commented:
Try this:

For Each folder In IO.Directory.GetDirectories("c:\")
    ListBox1.Items.Add(IO.Path.GetFileName(folder))
Next

Open in new window

0
 
CodeCruiserCommented:
Also change

WebBrowser1.Navigate("C:\sourcefolder\")

to

WebBrowser1.Navigate(Checkedlistbox1.selecteditem.tostring() & ".htm")
0
 
RobertoFreemanoAuthor Commented:
Thanks Guys, I'll test this asap ;)
0
 
RobertoFreemanoAuthor Commented:
Thanks guys ;)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now