Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 8th, 2006, 12:44 PM
Friend of Wrox
 
Join Date: Nov 2005
Location: Rotterdam, , Netherlands.
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
Reply With Quote
  #2 (permalink)  
Old February 8th, 2006, 07:52 PM
Authorized User
 
Join Date: Feb 2006
Location: Verona, Italy, Italy.
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
Reply With Quote
  #3 (permalink)  
Old February 9th, 2006, 04:23 AM
Friend of Wrox
 
Join Date: Nov 2005
Location: Rotterdam, , Netherlands.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:11 AM.


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