当前位置:编程学习 > asp >>

asp 显示目录存在时显示此目录下的所有子目录

asp教程 显示目录存在时显示此目录下的所有子目录
 '参数:目录名(相对路径) ,对象
 Public Function ShowFolderList(folderUrl,tag,listType)
  Dim f,f1,fc,i,temp,disabledtf
  On Error Resume Next
  temp = Server.MapPath(folderUrl)
  If oFso.FolderExists(temp) Then
   Set f = oFso.GetFolder(temp)
   Set fc = f.SubFolders
   If listType = "list" Then
    disabledtf = "disabled"
   Else
    disabledtf = ""
   End If
   ShowFolderList = "<table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1"">"& Chr(13)
   ShowFolderList = ShowFolderList &"<tr class=""defaulttitletd"">"& Chr(13)
   ShowFolderList = ShowFolderList &"<td width=""3%""><input type=""checkbox"" name=""chkAll"" id=""chkAll"" value="""" title=""选中所有"" onClick=""javascript教程:selectAllCheckBox('path',this.id);checkDisabled('button',getValueList('input'));"" "& disabledtf &" /></td>"& Chr(13)
   ShowFolderList = ShowFolderList &"<td>目录名/文件名</td>"& Chr(13)
   ShowFolderList = ShowFolderList &"<td width=""20%"" align=""right"">大小</td>"& Chr(13)
   ShowFolderList = ShowFolderList &"</tr>"& Chr(13)
   i = 0
   For Each f1 in fc
    ShowFolderList = ShowFolderList &"<tr "& Lib.DefaultTrStyle(i,"defaulttr","defaultmod","defaulttdover") &">"& Chr(13)
    ShowFolderList = ShowFolderList &"<td><input name=""path"" id=""path"" type=""checkbox"" value="""& folderUrl &"/"& f1.name &""" onClick=""javascript:checkDisabled('button',getValueList('input'));"" "& disabledtf &" /></td>"& Chr(13)
    ShowFolderList = ShowFolderList &"<td><span style=""cursor:pointer"" onmouseover=""javascript:xmlHttpPost('../Inc/XmlHttp.asp','action=preview&showType=folder&filepath="& folderUrl &"/"& f1.name &"',0,0,'preview')"" onClick=""javascript:location.href='?tag="& tag &"&listtype="& listType &"&folderUrl='+ escape('"& folderUrl &"/"& f1.name &"')""><img src=""../Skin/"& Lib.GetCookie("style") &"/Images/System/Closed_Folder.gif"" align=""absmiddle"" />"& f1.name &"</span></td>"& Chr(13)
    ShowFolderList = ShowFolderList &"<td align=""right"">"& GetfolderInfo(folderUrl &"/"& f1.name)(0) &"</td>"& Chr(13)
    ShowFolderList = ShowFolderList &"</tr>"& Chr(13)
    i = i + 1
   Next
   ShowFolderList = ShowFolderList &"</table>"& Chr(13)
  Else
   ShowFolderList = "-"
  End if
  If Err <> 0 Then Err.Clear
  Set f = Nothing
  Set fc = nothing
 End Function

补充:asp教程,技巧与性能优化
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,