Recursion using a component

Results 1 to 2 of 2

Thread: Recursion using a component

  1. #1
    Join Date
    Dec 1969

    Default Recursion using a component

    I&#039m trying to build a tree using VisualAsp tree component with the FileSystemObject. I&#039m using recursion to loop through the files and subdirectories. It works fine until I uncomment the IterateThroughDirectory call. Then I get an error:This key is already associated with an element of this collection.<BR><BR>Does anyone have an idea how I can do this?<BR><BR>&#060;%<BR>Sub IterateThroughDirectory(objFolder)<BR><BR> &#039Now, use a for to loop through the Files collection<BR> <BR> Dim objFile<BR> For Each objFile in objFolder.Files<BR> <BR> icount = icount + 1<BR> FILE_KEY = icount<BR> my_FILE_KEY = "C"&FILE_KEY<BR> RESPONSE.WRITE my_FILE_KEY<BR> Set Nodex = TreeView.Nodes.Add("R", 4, my_FILE_KEY,, "doc.gif", ,, , "Files")<BR> &#039IterateThroughDirectory objFolder<BR> Next<BR><BR> Dim objSubFolder<BR> For Each objSubFolder in objFolder.SubFolders<BR> Set Nodex = TreeView.Nodes.Add("R", 4, objSubFolder,, "clsdfold.gif", "openfold.gif",, , "subfolders")<BR> <BR> &#039IterateThroughDirectory objSubFolder<BR> <BR> Next<BR>End Sub<BR><BR><BR><BR> Dim objFSO<BR> Set objFSO = Server.CreateObject("Scripting.FileSystemObject")< BR><BR> Dim strCurrentFolder<BR> strCurrentFolder = "e:WWWppcinfosubscriptions abi\"<BR> Dim objFolder<BR> Set objFolder = objFSO.GetFolder(strCurrentFolder)<BR> &#039NODE = , , "R"<BR> Set Nodex = TreeView.Nodes.Add( , ,"R", objFolder, "clsdfold.gif", "openfold.gif", objFolder, , "Root Folder")<BR> IterateThroughDirectory objFolder<BR><BR><BR><BR> <BR><BR><BR>&#039Set Nodex = TreeView.Nodes.Add( , ,"R", "Sample Node", "clsdfold.gif", "openfold.gif", "your.asp", , "Tooltip")<BR>&#039Set Nodex = TreeView.Nodes.Add("R", 4, "C1", "Sample Node", "clsdfold.gif", "openfold.gif", "your.asp", , "Tooltip")<BR>&#039Set Nodex = TreeView.Nodes.Add("R", 4, "C2", "Sample Node", "clsdfold.gif", "openfold.gif", "your.asp", , "Tooltip")<BR>&#039Set Nodex = TreeView.Nodes.Add("C2", 4, "C3", "Sample Node", "clsdfold.gif", "openfold.gif", "your.asp", , "Tooltip")<BR>&#039Set Nodex = TreeView.Nodes.Add("R", 4, "C4", "Sample Node", "clsdfold.gif", "openfold.gif", "your.asp", , "Tooltip")<BR>&#039Set Nodex = TreeView.Nodes.Add(, , "R1", "Sample Node", "clsdfold.gif", "openfold.gif", "your.asp", , "Tooltip")<BR><BR><BR><BR>%&#062;<BR><BR>&#060;%<B R>TreeView.Show<BR>%&#062;<BR><BR>&#060;%<BR>Set TreeView = Nothing<BR><BR>%&#062;<BR>&#060;/body&#062;<BR>&#060;/html&#062;<BR><BR><BR>

  2. #2
    Steve Cimino Guest

    Default RE: Recursion using a component

    Make your sub into a function.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts