ASP code for traversing all the folders on the site

Source: Internet
Author: User

<! -- Traverse all site folders -->
<Style>
<! --
Body {font-size: 12px ;}
-->
</Style>
<Script language = "VBScript">
<! --
Sub fsubmit ()
Form1.submit
End sub
-->
</SCRIPT>
<Form name = "form1" method = "Post" Action = "findfolder. asp">
<Select size = "1" name = "fpath" onchange = "fsubmit ()">
<Option value = "0" selected> -- select -- </option>
<Option value = "/"> entire site </option>
<Option value = "."> current directory </option>
<%
Dim FSO, objfolder, objfile, strpath
Set FSO = server. Createobject ("scripting. FileSystemObject ")

Strpath = "."
Call BL (strpath)

Function BL (strpath)
Set objfolder = FSO. getfolder (server. mappath (strpath ))

For each objsubfolder in objfolder. subfolders
Response. write "<option value = '" & strpath & "\" & objsubfolder. name & "'>" & replace (strpath ,". "," ") &" \ "& objsubfolder. name & "</option>"
Call BL (strpath & "\" & objsubfolder. Name)
Next

End Function
%>
</SELECT>
</Form>

<%
Fpath = request. Form ("fpath ")

If fpath <> "0" and fpath <> empty then

Response. write "<font color =" "# ff0000"> current folder: "& replace (fpath ,". "," ") &" </font> <br>"

Set objfolder = FSO. getfolder (server. mappath (fpath ))

For each objsubfolder in objfolder. subfolders
Response. Write "subfolders:" & objsubfolder. Name & "<br>"
Next

Response. Write "<br>"

For each objfile in objfolder. Files
Response. Write "file name:" & objfile. Name & "<br>"
Next

Set objfolder = nothing

End if
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.