ASP Display directory All files

Source: Internet
Author: User

ASP Tutorial Displays directory all files
option   explicit
dim   infopath                      ' Current path   
Dim    serverpath                  ' Server path   
dim   objfso                          ' File Components   
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")        ' get 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.