Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 8th, 2006, 12:44 PM
Friend of Wrox
 
Join Date: Nov 2005
Posts: 223
Thanks: 0
Thanked 0 Times in 0 Posts
Default return files in folder

Hi,

I need a script that writes all files and their locations.

Example:
I have the folder C:\Temp

Now I want all files to be displayed like this:

/folder1/image.jpg
/folder1/readme.txt
/folder2/anotherfile.exe
/folder2/subfolder/file.txt
/folder2/subfolder/subfolderInsubfolder/file.txt

thnx


__________________________________________________ ________
This is my junk I'm gona eat it
 
Old February 8th, 2006, 07:52 PM
Authorized User
 
Join Date: Feb 2006
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Dj Kat !

Code:
<% 
Dim fso, sRoot 
Set fso = Server.CreateObject("Scripting.FileSystemObject") 
 sRoot = "C:\Temp"'Server.MapPath("/")
 buildTree(sRoot) 
 Function buildTree(path)
   Dim dl, d, fl, f
   Set dl = fso.GetFolder(path).SubFolders 
     Response.Write "[list]"
     For Each d In dl
       Response.Write "<li>" & d.Name  "</li>"
       Response.Write "[list]"
   Set fl = fso.GetFolder(d.path).Files
     For Each f In fl
       Response.Write "<A HREF='"& Replace(f.path, sRoot, "") & "'"">" &_ 
       "<li>" & f.Name & "</A><br>"
     Next
   Set fl = Nothing

 Response.Write "</ul>"
 
 buildTree(d.Path)  
  Next

 Set dl = Nothing
   Response.Write "</ul>" 
 End Function 
 
Set fso = Nothing
%>






www.steweb.net
 
Old February 9th, 2006, 04:23 AM
Friend of Wrox
 
Join Date: Nov 2005
Posts: 223
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanx a lot this does exactly what I want

I made some adjustments to make it to my liking
Code:
<% 
Dim fso, sRoot 
Set fso = Server.CreateObject("Scripting.FileSystemObject") 
 sRoot = "C:\Temp"'Server.MapPath("/")
 buildTree(sRoot) 
 Function buildTree(path)
   Dim dl, d, fl, f
   Set dl = fso.GetFolder(path).SubFolders 
     For Each d In dl
       'Response.Write  d.Name & "<br />"
   Set fl = fso.GetFolder(d.path).Files
     For Each f In fl
       Response.Write "\" & d.Name & "\"&f.Name & "<br />"
     Next
   Set fl = Nothing

 
 buildTree(d.Path)  
  Next

 Set dl = Nothing
   Response.Write "</ul>" 
 End Function 
 
Set fso = Nothing
%>
__________________________________________________ ________
This is my junk I'm gona eat it





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Zip files within a folder Udi C# 2 January 25th, 2007 12:45 AM
Files in folder - Report Jane27 C# 2 November 27th, 2006 09:03 AM
Files need to move different folder surendran PHP How-To 2 June 20th, 2006 10:27 PM
FILES in FOLDER luma SQL Server DTS 0 June 9th, 2005 01:53 AM
opening folder and return files treasacrowe Classic ASP Basics 3 February 18th, 2005 02:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.