Iterating back through filesystem

Results 1 to 2 of 2

Thread: Iterating back through filesystem

  1. #1
    Join Date
    Dec 1969

    Default Iterating back through filesystem

    Hi,<BR><BR>I&#039;m trying to build a loop that for each progression of the loop sets a filesystem object pointer back one step along the file tree. For example if my file tree goes<BR><BR>C:Inetpubwwwrootscriptslive est<BR><BR>and the loop went round three times the filesystem object needs to be left pointing at<BR><BR>C:Inetpubwwwroot<BR><BR>I know you cna achieve this effect by using the parentfolder property of the folder object but how do you then get the parentfolder of that folder and so on?<BR><BR>Hope this makes sense!<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Iterating back through filesystem

    Use an iterative function, a bit like:<BR><BR>&#060;%<BR>Levels = 3<BR>test = GetParent ("C:WINNTsystem32spooldrivers", Levels)<BR><BR>Function GetParent (FolderName, CurrentLevel) <BR> Set FolderObject = CreateObject("Scripting.FileSystemObject")<BR> Set fldThisFolder = FolderObject.GetFolder(FolderName)<BR> ParentFolderName = fldThisFolder.ParentFolder<BR> Response.write "Uplevel " & CurrentLevel & ":" & ParentFolderName & "<BR>"<BR> If CurrentLevel&#062;1 Then<BR> CurrentLevel = CurrentLevel-1<BR> GetParent ParentFolderName, CurrentLevel<BR> Else<BR> GetParent = ParentFolderName<BR> End If<BR>End Function <BR>%&#062;

Posting Permissions

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