Solved

small app debug, c#, vs2012

Posted on 2014-12-25
7
106 Views
Last Modified: 2014-12-25
I am following the link below to create file/folder tree-view similar to file explore:
http://msdn.microsoft.com/en-us/library/ms171645%28v=vs.80%29.aspx

What I have built is not working. I wonder if you could possibly take a look at this 60KB file at:  https://onedrive.live.com/?cid=420CDD6A13807C9B&id=420CDD6A13807C9B%21116 to see how I may be able to fix this:
0
Comment
Question by:Mike Eghtebas
  • 4
  • 3
7 Comments
 
LVL 51

Expert Comment

by:HainKurt
ID: 40518011
whats the issue you are having?
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 40518015
adding some fix here & there... here we go:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace FilesAndFolderInTreeView
{

    public partial class Form1 : Form
    {

        private void PopulateTreeView()
        {
            TreeNode rootNode;

            DirectoryInfo info = new DirectoryInfo(@"C:\");
            if (info.Exists)
            {
                rootNode = new TreeNode(info.Name);
                rootNode.Tag = info;
                GetDirectories(info.GetDirectories(), rootNode);
                treeView1.Nodes.Add(rootNode);
            }
        }

        private void GetDirectories(DirectoryInfo[] subDirs, TreeNode nodeToAddTo)
        {
            TreeNode aNode;
            DirectoryInfo[] subSubDirs;
            foreach (DirectoryInfo subDir in subDirs)
            {
                aNode = new TreeNode(subDir.Name, 0, 0);
                aNode.Tag = subDir;
                aNode.ImageKey = "folder";
                subSubDirs = subDir.GetDirectories();
                if (subSubDirs.Length != 0)
                {
                    GetDirectories(subSubDirs, aNode);
                }
                nodeToAddTo.Nodes.Add(aNode);
            }
        }

        public Form1()
        {
            InitializeComponent();
            PopulateTreeView();
            //this.treeView1.NodeMouseClick += new TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseClick);
        }

    }

}

Open in new window

0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 40518024
Sorry about for not stating the problem correctly. It doesn't have error. I just doesn't populate the controls (TreeView or ListView).
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 51

Expert Comment

by:HainKurt
ID: 40518027
without writing any line of code, how come can you expect it to run like an explorer?

anyways, just copy paste the code ^^^ replacing your whole code...
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 40518034
I have totally messed up this application. I replaced old Form1 with another Form2 (then renamed it to Form1) in the process most of my code was deleted. I will go for a run now. After that break, I will shape it up so we can continue with it.

Mike
0
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 40518036
all the code is ^^^, just copy & paste (delete all your code first)
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 40518070
Hi Hain,

I am sure what you are saying would work. But unfortunately I have deleted the entire project and started all over again which in a sense is good practice for me.

Good news is that it is working now.

Thanks,

Mike
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
New to SOAP and need some direction 10 46
Vb. Net application freezes 9 30
User Authentication using Digital Certificate 2 26
Finally almost got it 5 20
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

895 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

11 Experts available now in Live!

Get 1:1 Help Now