ASP lists all files in this directory when the directory exists

Source: Internet
Author: User

' Parameters: Directory name (relative path), object, page number, several pages per page
Public Function showfilelist (folderurl,tag,page_num,page_size,listtype)
Dim F,f1,fc,i,temp,page_count,disabledtf,tagexp
On Error Resume Next
temp = Server.MapPath (FolderUrl)
If ofso.folderexists (temp) Then
Set f = ofso.getfolder (temp)
Set FC = F.files
If listtype = "List" Then
DISABLEDTF = "Disabled"
Else
DISABLEDTF = ""
End If
Showfilelist = "<table width=" "100%" "border=" "0" "cellspacing=" "1" "cellpadding=" "1" ">" & Chr (13)
i = 0
Page_count = Int (FC. Count/page_size)
If FC. Count/page_size > Page_count Then page_count = page_count + 1
For each F1 in FC
Tagexp = ""
If tag <> "" Then
Tagexp = "onclick=" javascript Tutorial: Window.opener.document.getElementById (' & Tag & '). Value = ' "& FolderUrl & "/" & F1.name & "'; Window.close () "" "" "
Else
Tagexp = "onclick=" "Javascript:window.open" ("& FolderUrl &"/"& F1.name &"); "" "
End If
If i >= CInt (page_num-1) * page_size) and I <= CInt (page_num * page_size-1) Then
Showfilelist = showfilelist & "<tr" & Lib.defaulttrstyle (i, "defaulttr", "Defaultmod", "Defaulttdover") & ">" & Chr (13)
Showfilelist = showfilelist & "<td width=" "3%" "><input name=" "Path" "id=" "Path" "Type=" "checkbox" "Value=" "& FolderUrl &"/"& F1.name &" "onclick=" "javascript:checkdisabled (' button ', getvaluelist (' input ')" ;"" "& DISABLEDTF &"/></td> "& Chr (13)
Showfilelist = showfilelist & "<td><span style=" "Cursor:pointer" "onmouseover=" "Javascript:xmlhttppost" ( '.. /inc/xmlhttp.asp ', ' action=preview&showtype=file&filepath= ' + Escape (' "& FolderUrl &"/"& F1.name & "'), 0,0, ' preview ')" "" & Tagexp & ">" & Getfilepic (Getfileextname (F1.name) (1)) & "" & F1.name & "</span></td>" & Chr (13)
Showfilelist = showfilelist & "<td width=" "20%" "align=" "Right" ">" & GetFileInfo (FolderUrl & "/" & F1.name) (0) & "</td>" & Chr (13)
Showfilelist = showfilelist & "</tr>" & Chr (13)
ElseIf i >= CInt (page_num * page_size) Then
Exit for
End If
i = i + 1
Next
Showfilelist = showfilelist & "</table>" & Chr (13)
If FC. Count > 0 Then showfilelist = showfilelist & "<div class=" "MarginTop" ">" & Irs.pagelistbar (Page_num,page _COUNT,FC. Count,page_size, "Folderurl=" & FolderUrl & "&tag=" & Tag & "&listtype=" & ListType & " & "1) &" </div> "& Chr (13)
Else
Showfilelist = "-"
End If
If Err <> 0 Then Err.Clear
Set F = Nothing
Set FC = Nothing
 end Function

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.