Hi all .. i have given this code in my project.. it is showing
Access to the path 'C:\Documents and Settings' is denied.
I dont know what is wrong.. this code works if i give the path different...
can any help me...
Thnaks
vince
private void FileView()
{
TreeNode RootNode = new TreeNode("Root");
treeView2.Nodes.Add(RootNode);
PopulateTreeView(@"C:\", RootNode);
}
public void PopulateTreeView(string directory, TreeNode Node)
{
string[] Directories = Directory.GetDirectories(directory);
string[] Files = Directory.GetFiles(directory);
foreach (string folder in Directories)
{
TreeNode FolderNode = new TreeNode(Path.GetFileName(folder));
Node.Nodes.Add(FolderNode);
this.PopulateTreeView(folder, FolderNode);
}
foreach (string file in Files)
{
TreeNode FileNode = new TreeNode(Path.GetFileName(file));
Node.Nodes.Add(FileNode);
}
}