error when using source code for treeview
-
hi From the code project i downloaded a source code and used in my project and got the following error: 1.The best overloaded method match for 'Microsoft.Web.UI.WebControls.TreeNodeCollection.Add(Microsoft.Web.UI.WebControls.TreeNode)' has some invalid arguments
nodes.Add( Node( p, p.Substring( path.Length ), "file" ) )
nodes.Add(Node("",p.Substring( path.Length + 1), "folder" ) );2.Argument '1': cannot convert from 'Test.WebForm7' to 'Microsoft.Web.UI.WebControls.TreeNode' it comes near
n.Text = nodeText.ToString(); **return n;**
It is from TreeView in a customized tool I am unable to understand what went wrong thanks in advance sasi
-
hi From the code project i downloaded a source code and used in my project and got the following error: 1.The best overloaded method match for 'Microsoft.Web.UI.WebControls.TreeNodeCollection.Add(Microsoft.Web.UI.WebControls.TreeNode)' has some invalid arguments
nodes.Add( Node( p, p.Substring( path.Length ), "file" ) )
nodes.Add(Node("",p.Substring( path.Length + 1), "folder" ) );2.Argument '1': cannot convert from 'Test.WebForm7' to 'Microsoft.Web.UI.WebControls.TreeNode' it comes near
n.Text = nodeText.ToString(); **return n;**
It is from TreeView in a customized tool I am unable to understand what went wrong thanks in advance sasi
What is the type of p parameter? << >>
-
What is the type of p parameter? << >>
used for loop where p is string for directories here is the full code
// recursive method to load all folders and files into tree
private void GetFolders( string path, TreeNodeCollection nodes )
{
// add nodes for all directories (folders)
string[] dirs = Directory.GetDirectories( path );
foreach( string p in dirs )
{
string dp = p.Substring( path.Length );
nodes.Add(Node("",p.Substring( path.Length + 1), "folder" ) );
}// add nodes for all files in this directory (folder) string\[\] files = Directory.GetFiles( path, "\*.\*" ); foreach( string p in files ) { nodes.Add( Node( p, p.Substring( path.Length ), "file" ) ); } // add all subdirectories for each directory (recursive) for( int i = 0; i < nodes.Count; i++ ) { if ( nodes\[ i \].Type == "folder" ) { GetFolders( dirs\[ i \] + "\\\\", nodes\[i \].Nodes ); } } }