<% Function UnMapPath( Path ) ' UnMapPath = Replace(Mid(Path, Len(Server.MapPath("/")) + 1), "\", "/") UnMapPath = Replace(Mid(Path, Len(Server.MapPath("/")) - 1), "\", "/") End Function Function MakeFolderHREF( AspPath, Path ) URLPath = Server.URLEncode(UnMapPath(Path) ) URLPath = Mid(URLPath, 3) MakeFolderHREF = "" End Function Function MakeFileHREF( Path ) MakeFileHREF = "" End Function %> <% ' 讀取資料夾名稱及 ASP 程式的路徑 ' Sub ListDir() Dim AspPath Dim strHtml Dim FolderStr Folder=Request("Folder") If Folder = "" Then ' 不是本程式設定的目錄,則檢查TopFolder的設定 If Not IsObject(Session("TopFolder")) Then TopFolder = Request("TopFolder") ' 存入Session,做其他使用 If TopFolder="" Then Response.Write "程式結束!!!" Response.End Else Session("TopFolder")=Trim(TopFolder) End If End If Folder = Session("TopFolder") End If AspPath = Request.ServerVariables("PATH_INFO") ' 輸出資料夾名稱 ' Response.Write "

TopFolder= " & Session("TopFolder") & "

" Response.Write "

下載資料目錄 " & Replace(Mid(Folder & "/" ,Len(Session("TopFolder"))+1),"/","\") & " 之內容:


" ' Response.Write "請壓滑鼠右鍵後,選另存目標
" On Error Resume Next Set fs = Server.CreateObject("Scripting.FileSystemObject") Set fd = fs.GetFolder( Server.MapPath(Folder) ) ' Response.Write "Mappath=" & Server.MapPath(Folder) & "
" ' Response.Write "AspPath=" & AspPath & "
" ' 輸出「上一層資料夾」 If Folder <> Session("TopFolder") Then ' 是否有上一層資料夾 HREF_Path = MakeFolderHREF(AspPath, fd.ParentFolder.Path) ' Response.Write "sfd.name=" & sfd.Name & "
" Response.Write HREF_Path & "[上一層資料夾]

" ' Response.Write "fd.ParentFolder.Path=" & fd.ParentFolder.Path & "
" ' Response.Write "UnMapPath(fd.ParentFolder.Path)=" & UnMapPath(fd.ParentFolder.Path) & "
" End If ' 輸出資料夾 For Each sfd In fd.SubFolders HREF = " " ' HREF = HREF & MakeFolderHREF(AspPath, sfd.Path ) ' HREF = HREF & MakeFolderHREF(strWebHome, sfd.Path ) ' Response.Write HREF & sfd.Name & "
" ' HREF = HREF & "" & sfd.Name & "
" FolderStr= Server.UrlEncode(Folder & "/" & sfd.Name) HREF = HREF & "" & sfd.Name & "
" Response.Write HREF Next Response.Write "
" ' 輸出檔案 For Each f In fd.Files HREF = " " & "" Response.Write HREF & f.Name & "
" Next %>