Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 3rd, 2004, 03:23 PM
Registered User
 
Join Date: Feb 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need help creating Check List Box of Windows Dir

I want to try and build my own backup program and right now I am stuck trying to find a solution. I want to create a Check List Box of the Windows Directory. The idea is to have the user put a check next to the folder they want to backup. The List Box must be able to read all the files and folders in the windows directory.

How can I do this?

 
Old August 9th, 2004, 09:15 PM
Registered User
 
Join Date: Jul 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you going to use a control to display the windows directory, a treeview is better than the check list box, you can use check box in treeview after u set the property of it.

hope it can help

 
Old August 10th, 2004, 11:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Look up the System.IO namespace. You will need to use recursion to scan folders within folders. Try something like this:

----------------------------------------------------
Sub ScanPath(ByVal PathToScan As String, ByRef CurNode As TreeNode)
        Dim CurFolder As String
        Dim TotFolders() As String
        TotFolders = System.IO.Directory.GetDirectories(PathToScan)
        For Each CurFolder In TotFolders
            Dim TNode As TreeNode
            TNode = New TreeNode(CurFolder)
            CurNode.Nodes.Add(TNode)
            PathToScan = CurFolder
            ScanPath(PathToScan, TNode)
        Next
End Sub

---------------------------
Then, this example uses a button to fill the treeview:
----------------------------

Private Sub btnGetFolders_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetFolders.Click
        Dim TNode As New TreeNode
        TNode = TreeView1.Nodes.Add("C:\windows")
        Cursor.Current = Cursors.WaitCursor
        ScanPath("C:\windows", TNode)
End Sub
----------------------------

This will get you the folders. See if you can come up with the code to get the files. :)

J





Similar Threads
Thread Thread Starter Forum Replies Last Post
Grab Values From List Box into Text Box phungleon VB How-To 2 June 19th, 2008 10:33 PM
multi-column list box values moved to 2nd list box sbmvr Access VBA 1 May 14th, 2007 01:58 PM
select box/List box alphabetic sort sasidhar79 Javascript How-To 3 November 10th, 2004 03:04 AM
Populate List Box by Combo Box Selection mmcdonal Access 2 June 15th, 2004 12:08 PM
Search using drop down list box and a text box tcasp Classic ASP Basics 1 July 31st, 2003 02:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.