?
Solved

TreeView

Posted on 2006-03-21
2
Medium Priority
?
200 Views
Last Modified: 2012-05-05
Hi,

EE helped me with http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_21704165.html

is there a way that can display the contents of the folder with open/close function?thx
0
Comment
Question by:mcrmg
2 Comments
 
LVL 10

Accepted Solution

by:
thefritterfatboy earned 400 total points
ID: 16256335
Try this:
(All folders are closed by default)

<%@ Language = VBScript %>
<% option explicit %>

<html>
<body>
<%

Dim FileCount, FolderCount, TimeStart, TimeEnd, TotalSpace, IterationCount, strRelativePath, File, Folder

FileCount = 0
FolderCount = 0
TotalSpace = 0
IterationCount = 0

TimeStart = Timer()

Call PrintFolderStructure(Server.Mappath("."))

TimeEnd = Timer()

Response.Write "<br><br>Total Folders: " & FolderCount
Response.Write "<br>Total Files: " & FileCount
Response.Write "<br>Space Used: " & FormatNumber(TotalSpace/1024,0) & " Kb"
Response.Write "<br>Time: " & FormatNumber(TimeEnd - TimeStart,2) & " Seconds"


%>
</body>
</html>
<%

Sub PrintFolderStructure(path)

  dim objFSO, objFolder, rootPath, strCurrentPath

  Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

  Set objFolder = objFSO.GetFolder(path)
 
   IterationCount = IterationCount + 1
  Response.Write vbCrLf
 
  'Get virtual root

  rootPath = Server.MapPath(".")

  strCurrentPath = Mid(path,len(rootPath)+1)
  strRelativePath = strCurrentPath

  If len(strCurrentPath) = 0 Then
      strCurrentPath = "\"
  Else
     strRelativePath = strRelativePath & "/"
  End If

  Response.Write "<blockquote>" & vbcrlf

  If IterationCount mod 20 = 0 Then
     Response.Flush
  End If
  dim isFolderOpen
  isFolderOpen = (clng(request.querystring("open")) = -1)

  Response.Write "<b><a href=""" & request.servervariables("SCRIPT_NAME") & "?path=" & strCurrentPath & "&open="
      if isFolderOpen and request.querystring("path") = strCurrentPath then
            response.write clng(false) & """>" & strCurrentPath & "</a></b><br>"
      else
            response.write clng(true) & """>" & strCurrentPath & "</a></b><br>"
      end if


if isFolderOpen and request.querystring("path") = strCurrentPath then

   For Each File in objFolder.Files
    'This code runs for each file in a folder
        FileCount = FileCount + 1
        TotalSpace = TotalSpace + File.Size
        Response.Write "<a href=" & chr(34) & Replace(strRelativePath,"\","/") & File.Name  & chr(34) & " >" & File.Name & "</a>&nbsp;&nbsp; (<i style=""font-size: small;"">" & File.DateLastModified & ") " & FormatNumber(File.Size,0) & " bytes</i><br>" & vbCrLf
  Next
end if
  For Each Folder in objFolder.SubFolders

   'This code runs for each subfolder


      'Sub calls itself passing the path of the subfolder
       FolderCount = FolderCount + 1
       PrintFolderStructure(Folder.Path)

  Next

  Response.Write "</blockquote>"
 
   Set objFSO = Nothing

End Sub


'PrintFolderStructure("c:/inetpub/")
%>
0
 

Author Comment

by:mcrmg
ID: 16257987
Thank you
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Loops Section Overview
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question