Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8293733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:55:51+00:00 2026-06-08T13:55:51+00:00

I have a folder in my C: drive that I want to access as

  • 0

I have a folder in my C: drive that I want to access as soon as my form loads. I don’t want to scroll through opening each node everytime. I’m wanting to use a treeview as I know how to use a lot of the features in these and it will suit my purpose.

I shall give you an example of what i am wanting using a basic file structure:
C:\Users\user\Documents\Visual Studio 2010\Projects

This would take me a number of nodes to gain access to if I was to to it through the entire treeview. I want my treeview to to start with, so the main node to be
Projects

How would I go about doing this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:55:52+00:00Added an answer on June 8, 2026 at 1:55 pm

    I am sure that the answer above would work. However i managed to sort it out by doing:

            Dim backupfolder As String = netpath & "\MANUFPC BACKUP PROCESS\" & site & "\" & factory & "\" & line & "\" & pc
    
            Dim mRootNode As New TreeNode
            mRootNode.Text = pc
            mRootNode.Tag = backupfolder
            mRootNode.Nodes.Add("*DUMMY*")
            'adds plus icon to allow extension
            backupFolderDirectory.Nodes.Add(mRootNode)
    

    then the two other functions:

    Private Sub TreeView1_BeforeCollapse(ByVal sender As Object, ByVal e As TreeViewCancelEventArgs) Handles backupFolderDirectory.BeforeCollapse
        ' clear the node that is being collapsed
        e.Node.Nodes.Clear()
        ' add a dummy TreeNode to the node being collapsed so it is expandable
        e.Node.Nodes.Add("*DUMMY*")
    End Sub
    
    Private Sub TreeView1_BeforeExpand(ByVal sender As Object, ByVal e As TreeViewCancelEventArgs) Handles backupFolderDirectory.BeforeExpand
        ' clear the expanding node so we can re-populate it, or else we end up with duplicate nodes
        e.Node.Nodes.Clear()
    
        ' get the directory representing this node
        Dim mNodeDirectory As DirectoryInfo
        mNodeDirectory = New DirectoryInfo(e.Node.Tag.ToString)
        ' add each subdirectory from the file system to the expanding node as a child node
        Try
            For Each mDirectory As DirectoryInfo In mNodeDirectory.GetDirectories
                ' declare a child TreeNode for the next subdirectory
                Dim mDirectoryNode As New TreeNode
                Dim mystring(1) As String
                mystring(0) = mDirectory.FullName
                mystring(1) = "directory"
                ' store the full path to this directory in the child TreeNode's Tag property
                mDirectoryNode.Tag = mystring(0)
                ' set the child TreeNodes's display text
                mDirectoryNode.Text = mDirectory.Name
                ' add a dummy TreeNode to this child TreeNode to make it expandable
                mDirectoryNode.Nodes.Add("*DUMMY*")
                ' add this child TreeNode to the expanding TreeNode
                e.Node.Nodes.Add(mDirectoryNode)
            Next
    
            For Each mFiles As FileInfo In mNodeDirectory.GetFiles
                ' declare a child TreeNode for the next subdirectory
                Dim mFileNode As New TreeNode
                Dim mystring(1) As String
                mystring(0) = mFiles.FullName
                mystring(1) = "file"
                ' store the full path to this directory in the child TreeNode's Tag property
                mFileNode.Tag = mystring(0)
                ' set the child TreeNodes's display text
                mFileNode.Text = mFiles.Name
                ' add this child TreeNode to the expanding TreeNode
                e.Node.Nodes.Add(mFileNode)
            Next
    
        Catch ex As IOException
            'sets up 2 different exceptions then the last one catches other exceptions that could be made from adding folder/files etc
            e.Node.Remove()
            MsgBox("Device/Folder not accessible", MsgBoxStyle.OkOnly, "Device not Ready")
        Catch exc As NullReferenceException
            e.Node.Remove()
            MsgBox("Sorry this File/Folder can not be added", MsgBoxStyle.OkOnly, "Sorry")
        Catch exce As Exception
            e.Node.Remove()
            MsgBox("Device/Folder not accessible", MsgBoxStyle.OkOnly, "Device not Ready")
        End Try
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that writes to a folder on the C:\ drive. The
I have a wpf application that has a button for for each folder under
I have a folder on my hard drive, C:\Program Files\Microsoft SDKs, and I was
I have a dvd copied in my hard drive. It has a folder called
I have folder home/admin. In this folder there is index.php. When i access to
I have folder on which i want to apply security like the current user
I'm very new to Access and I don't have any experience. At work, I
Does anyone store their Repositories folder on a network drive that's backed up? Is
I have a folder in my C: drive as C:\app_config\java_app This folder contains some
I have a Windows form application with database in the folder of the project

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.