?
Solved

small app debug, c#, vs2012

Posted on 2014-12-25
7
Medium Priority
?
117 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 57

Expert Comment

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

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 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
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!

 
LVL 57

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 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 57

Accepted Solution

by:
HainKurt earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

752 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