利用fso顯示文件夾中的內容,包括子文件夾和文件名 <HTML> <HEAD><TITLE>fso顯示文件夾內容(子目錄和文件)</TITLE></HEAD> <style> body {font-size:12px;margin-top:20px;margin-left:20px;} </style> <BODY> <% '創建一個FileSystemObject對象的事例 Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject") '創建一個Folder對象 foldername=server.mappath("./") Set MyFolder=MyFileObject.GetFolder(foldername) i=0 '循環顯示其中文件夾 response.write "顯示文件夾:" For Each thing in MyFolder.subfolders Response.Write("<br>"&thing) i=i+1 Next response.write "<br>共有"&i&"個文件夾"
response.write "<p>顯示文件名" '循環顯示其中文件 i=0 For Each thing in MyFolder.Files Response.Write("<br>"&thing) i=i+1 Next response.write "<br>共有"&i&"個文件" %> </Body> </HTML>