ASP Display directory All files

Source: Internet
Author: User

Option Explicit
Dim InfoPath ' Current Path
Dim Serverpath ' Server Path
Dim objFSO ' File Component
Dim objfile ' File
Dim objfolder ' Directory
Dim objfoldercontents ' All Files
Dim objfoldercount ' Temporary Array variable-folder
Dim objfileitem ' Temporary Array variable-file

Infopath=request.servervariables ("Path_info") ' gets file relative path
Serverpath=server.mappath (InfoPath) ' Get file absolute path

set   objfso=createobject ("Scripting.FileSystemObject")        ' instance file components   
set   objfile=objfso.getfile (serverpath)                                        ' Read the path to the file   
set   objfolder=objfile.parentfolder                                               ' Gets the ancestor directory    according to the path of the file;

Set Objfoldercontents=objfolder.files ' All files paid to array

For each objfileitem in objfoldercontents ' Loop
Response.Write ("http://www.111cn.net/" & objfileitem.name& "<br/>") ' filename
Next

' Code two

Set fso = Server.CreateObject ("Scripting.FileSystemObject")
If Fso.folderexists (Request ("filepath")) then
Set objfolder = Fso.getfolder (Request ("filepath"))
For each objfile in Objfolder.files
Response.Write Objfile.name
Next
Set objfolder = Nothing
Set fso = Nothing

' This will show all files, but not folders
%>

Related Article

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.