TreeView

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
mcrmgAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

thefritterfatboyCommented:
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/")
%>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mcrmgAuthor Commented:
Thank you
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.