Solved

small app debug, c#, vs2012

Posted on 2014-12-25
7
113 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 55

Expert Comment

by:Huseyin KAHRAMAN
ID: 40518011
whats the issue you are having?
0
 
LVL 55

Expert Comment

by:Huseyin KAHRAMAN
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 34

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 55

Expert Comment

by:Huseyin KAHRAMAN
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 34

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 55

Accepted Solution

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

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

688 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