TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
John
NA
43
34.1k
Removing Nodes from treeview
Jul 15 2013 4:28 PM
Hi guys,
I have come to a little problem with my program. I am displaying files from 'Application.StartupPath' but I trying to get rid of the ParentNode which is the "Debug" folder.
I've got this so far, but no joy:
//Search
private void button10_Click(object sender, EventArgs e)
{
ListDirectorySearch(treeView1, Application.StartupPath);
//Search dir and populate
public TreeNode CreateDirectoryNodeSearch(DirectoryInfo directoryInfo)
{
var directoryNode = new TreeNode(directoryInfo.Name);
foreach (var directory in directoryInfo.GetDirectories())
if (directoryInfo.Name == "Debug")
{
treeView1.Nodes.Remove(directoryNode);
}
else
{
directoryNode.Nodes.Add(CreateDirectoryNodeSearch(directory));
}
foreach (var file in directoryInfo.GetFiles("*" + textBox1.Text + "*.PDF").
Union(directoryInfo.GetFiles("*.WMV").Union(directoryInfo.GetFiles("*.Mov"))))
directoryNode.Nodes.Add(new TreeNode(file.Name));
if (directoryNode.Nodes.Count == 0)
{
directoryNode.Nodes.Add("Sorry, No Books Here");
}
return directoryNode;
}
private void ListDirectorySearch(TreeView treeView, string path)
{
treeView.Nodes.Clear();
var rootDirectoryInfo = new DirectoryInfo(path);
treeView.Nodes.Add(CreateDirectoryNodeSearch(rootDirectoryInfo));
}
so to clarify, my result are:
Debug <---- (this is what I want to get rid of)
- folder1
- file1
- file2
- folder2
- newfile1
Thanks All
Reply
Answers (
3
)
print 2nd largest number ??
Get Logged in detail in windows form