Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. error when using source code for treeview

error when using source code for treeview

Scheduled Pinned Locked Moved ASP.NET
designregexhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sasire18
    wrote on last edited by
    #1

    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

    E 1 Reply Last reply
    0
    • S sasire18

      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

      E Offline
      E Offline
      enjoycrack
      wrote on last edited by
      #2

      What is the type of p parameter? << >>

      S 1 Reply Last reply
      0
      • E enjoycrack

        What is the type of p parameter? << >>

        S Offline
        S Offline
        sasire18
        wrote on last edited by
        #3

        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 );
        			}
        		}				
        	}
        
        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups