Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
10
Reply
How to call the method in the Page load?
chetan Allipur
Mar 13 2017 8:39 AM
342
Here this is my program
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SecondWeekContinues
{
public partial class TreeViewDemo : Form
{
public TreeViewDemo()
{
InitializeComponent();
ListDirectory(,"D:\\"); //See i am getting error here
}
private void ListDirectory(TreeView treeView, string path)
{
treeView1.Nodes.Clear();
var stack = new Stack<TreeNode>();
var rootDirectory = new DirectoryInfo(path);
var node = new TreeNode(rootDirectory.Name) { Tag = rootDirectory };
stack.Push(node);
while (stack.Count > 0)
{
var currentNode = stack.Pop();
var directoryInfo = (DirectoryInfo)currentNode.Tag;
foreach (var directory in directoryInfo.GetDirectories())
{
var childDirectoryNode = new TreeNode(directory.Name) { Tag = directory };
currentNode.Nodes.Add(childDirectoryNode);
stack.Push(childDirectoryNode);
}
foreach (var file in directoryInfo.GetFiles())
currentNode.Nodes.Add(new TreeNode(file.Name));
}
treeView1.Nodes.Add(node);
}
}
}
Reply
Upload Source Code
Select only zip and rar file.
Post
Reset
Answers (
10
)
Read the dynamic contents of a external website
asp.net web application search between two dates ...